9

A great resource for understanding row locking situations is the Record Locking Cheat Sheet (PDF link). Note at the top of page 2 that insert, update, and delete of Opportunities locks the parent Account. Since your batch job is running in parallel across its batches, the batches can independently attempt to gain locks on the same Account, resulting in ...


6

Since you already have a list of Ids (AcLst) you could query every Opportunity related to those Accounts, then populate a Map using the accountId as key and the list of opportunity as value. Map<Id, List<Opportunity>> mapAccountIdOpportunityList = new Map<Id, List<Opportunity>>(); for (Opportunity o : [SELECT Id, StageName, AccountId,...


5

Check out the OpportunityStage object. SELECT MasterLabel, DefaultProbability, ForecastCategory, IsClosed, IsWon FROM OpportunityStage


4

You're adding the error on the wrong sObject in after update context. From Trigger Exceptions: Triggers can be used to prevent DML operations from occurring by calling the addError() method on a record or field. When used on Trigger.new records in insert and update triggers, and on Trigger.old records in delete triggers, the custom error message is ...


3

Although the type of ContactId on Opportunity is Reference, it seems to be special unlike a traditional lookup field. Quoting relevant information from the Object reference of Opportunity: ID of the contact associated with this opportunity, set as the primary contact. Read-only field that is derived from the opportunity contact role, which is ...


3

This logic doesn't work: opp.StageName <> 'Closed Lost' || opp.StageName <> 'Closed - Lost' || opp.StageName <> 'Completed' || opp.StageName <> 'Closed Won' to find Opportunities that don't have any of those stages. Suppose the StageName is Closed Lost. The first clause evaluates to false, but the second one, opp.StageName <> '...


3

Field Sets You can add the checkbox fields to a Field Set on the Opportunity object. By accessing Schema.FieldSet records via the Describe API, your code can access these lists, which can be updated without a code deploy. Schema.FieldSet fs = Schema.SObjectType.Opportunity.fieldSets.MyTriggerFieldSet; Then, iterate over the results of getFields() on that ...


2

To add a field to a related list, it must either: 1. Be on the child object itself 2. Be on a (different)parent record to that child object where the relationship from child to (different) parent is master-detail. Account is not on the OpportunityProduct object, so you won't see it in the related list. You should see Opportunity, though. If you don't see ...


2

If you have a lot of fields and objects trying to load, this could cause performance problems. There's an article on how to improve performance you should take a look at. This article mentions accounts, but can be used for any misbehaving object that has too many fields and objects. Here's some things to try: By checking the "Enable Separate Loading of ...


2

Edited By is just an alias for the CreatedById field. You can query this to see who the edit was made by.


2

The proposed solution works well with automated processes that run under the profile name Automated Process but doesn't work with Apex code that runs under the same profile name of the user that launched it. A complete solution to my problem would be to create a dummy checkbox field (e.g. Status_Change_Enabled__c). Then use the following validation rule ...


2

In my opinion, the compiler ought to complain about this code, although it does not. You're doing a couple of things here that change the behavior of your code in ways you might not expect. List<Opportunity> opp = new List<Opportunity>(); for(Opportunity opp : trigger.new) Here, you've shadowed a declaration of a List<Opportunity> with a ...


2

This error occurs because there's too much logic going on. You either have too many Process Builders, flows, triggers, or some combination thereof that's causing this problem. The only two solutions are to limit the number of records you update, or optimize your org to use less CPU time. In theory, Salesforce allows updating 10,000 records at once in an ...


2

You may need a couple rollups here. The field names below should give you the idea. One field should count all children, the other should count only those whose StageName is 'New Opportunity'. SELECT Id FROM Account WHERE Assigned_Date__c < ... AND Owner.UserRole.Name IN (...) AND Total_Opportunity_Count__c = 1 AND New_Opportunity_Count__c = 1


2

You can use a before delete trigger on Opportunity which will prevent deletion of records for all users or certain profiles. Quick example: trigger OpportunitiesTrigger on Opportunity (before delete) { if (Trigger.isBefore && Trigger.isDelete) { for (Opportunity opp : Trigger.old) { opp.addError('You cannot delete Opportunity ...


2

I don't speak Ruby, but what you need to be doing to filter Contacts is querying against the OpportunityContactRole junction object. OpportunityContactRole connects Contacts to Opportunities and specifies Roles fulfilled by the Contact. Where you have contacts = client.query("select Id, FirstName, LastName, Email from Contact where AccountId = '#{o["...


2

There's no need to deal with AND or OR, because the first matching condition will stop the IF-ELSE chain from continuing. IF(Opportunity_Age__c < 100, "Short Term", IF(Opportunity_Age__c < 250, "Mid Term", IF(Opportunity_Age__c < 366, "Long Term", "365+") ) )


2

Grant the users Edit but not Delete on Opportunity via Profile or Permission Set. They will be able to delete Opportunity Products (aka OpportunityLineItem) on any Opportunities to which they have Read/Write sharing access.


2

When you have a reverse relationship, such that you can use a nested select, that means you have a direct relationship between that child and the parent. In this case you have OpportunityLineItem and Opportunity related via a field on OpportunityLineItem itself - the field is called OpportunityId and the relationship field is called Opportunity. You can, ...


2

Stage History are available in both classic and lightning if they are added to the page layout. In your case, it is not coming to Lightning. The possible reason is:- There are two component available in Lightning app builder that can show related list on a lightning page. They are:- Related List Related List-Single Realted list will show all the related ...


2

When a ContentVersion is first inserted to create a new file, it has no ContentDocument or ContentDocumentLink associated with it. These are created later. Hence this if(cv.ContentDocumentId != null) { contentDocumentIdSet.add(cv.ContentDocumentId); } will never execute on creation of a new file (only upon uploading a new version of an existing file),...


2

I was able to finally sort out where the on, was coming from, there were two problems with the form. The form was referencing "Amount" twice in the last line, once in the radio button and once in the text field and that's why it was expecting two values as an outcome, separated with a comma: <input type="radio" name="Amount"> $ <input type="number" ...


2

I think you can try to: Enable Path for your org. From Setup, enter Path Settings in the Quick Find box. Click Enable. To let users decide whether the path remembers its previous state, select Remember User's Path Preferences. If not selected, the path’s details are hidden when the page that the path is on loads. To Enable Path user should have Modify All ...


2

Transferring ownership of a record requires "Full" permission, not just "Write" permission. You have "Full" permission if you're the owner of the record, or a manager in the role hierarchy of the user that owns the record, or a user with Modify All Data. So, if you own the opportunity, you can freely give it to someone else, but you may not be able to take ...


2

You didn't set the cctOpp1.NumberOfEmployees field to a value over 99 so it would never enter your loop in the test class to create multiple accounts nor would it enter your logic in the trigger to create Opportunities as you have the same condition set (> 99). @IsTest public class TenIdenticalOpportunity { public static void createOpportunity() ...


2

If you look at the documentation under Activate and Deactivate Currencies, you'll discover there's an option when you activate a currency to set the number of decimal places that are displayed. Per the docs: To activate new currencies: From Setup, enter Manage Currencies in the Quick Find box, then select Manage Currencies. Click New in the ...


1

No. OpportunityShare, the underlying Share table, does not have an option to include access to the Account. Please note, however, that because of Implicit Sharing, the account is automatically shared with Read access (but not Edit) when the Opportunity is shared. You cannot change this default behavior.


1

Not using out-of-the-box functionality; you'd need to write a custom component to do that. Out of the box, you get one Path per object per record type. You can set up one path for each available record type. Steps for each path (1) are based on values in the picklist that you select when you set up the path. If you chose to set up your org to have a ...


1

I suggest simply deleting it in a trigger based on a 'deleteMe' checkbox on the OpportunityLineItem. The check box can be set using a quick action, and need not be on the page layout. The trigger runs in 'system mode' and will perform the delete regardless of user permission on the Opportunity. trigger DeleteOli on OpportunityLineItem(after insert, after ...


1

You didn't explicity say so in your post, but since your trigger method isn't doing any DML, I'm assuming that you're calling the method from a before update trigger. And this is the problem. Although it's not documented where in the Order of Execution a system field update like this takes place, a quick test shows that it hasn't happened in the before ...


Only top voted, non community-wiki answers of a minimum length are eligible