New answers tagged

0

First of all you are running your trigger after insert and not after update, so it will generate a new Order each time you create a new Opportunity only. Also, like Shaan commented, you need to define if there will only be one Order per Opportunity. If so you should consider adding an external key that will then be available for the upsert method. Best ...


0

Are you utilizing only one order from an opportunity? You could always select the Order ID based upon that opportunity ID in that case.


0

As stated in this link that has a similar error there is a description of why this is happening to which you can have a look. Apart from using before insert below is the explanation in above link: "This is because you are in an after insert/update trigger and the records are read only in that context as they have been written, but not committed, to the ...


0

You caanot update same reference in After trigger. Following code shall work - trigger updateSegment on Opt_Segment__c (before update){ for(Opt_Segment__c updatedSegment:Trigger.new) { updatedSegment.Valid__c='Override'; } }


0

// You can try this code trigger AccountCreationFromOpportunity on Opportunity (before update) { // Create a Map op Opportunity Id to Account // It would be trigger.New sicnce you would be updating in Update call. Trigger.old is readonly Map<Id,Account> mapOppIdToAccount = new Map<Id,Account>(); for(Opportunity o :trigger.New){ if(o....


2

This is working-as-designed, Triggers and Order of Execution second-to-last bullet Exception. When a record is updated and subsequently triggers a workflow rule field update, Trigger.old in the last update trigger doesn’t contain the version of the object immediately before the workflow update, but the object before the initial update was made. For example, ...


2

Your error: FATAL_ERROR System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Related Record ID: id value of incorrect type: 0051U000002ZdEiQAK: [RelatedRecordId] indicates 0051U000002ZdEiQAK which is a User record ID, is incorrect type. It's because RelatedRecordId does not accept Id of type User. Please see ...


1

trigger OpportunityTrigger on Opportunity(before update){ if(Trigger.isbefore ) { if(Trigger.isUpdate ) { List<Opportunity> opps = new List<Opportunity>(); for(Opportunity o : Trigger.new){ if(o.AccountId == NULL){ opps.add(o); } } ...


0

Future methods were the answer ContentDocumentTriggerHandler public with sharing class ContentDocumentTriggerHandler { public static void handleBeforeDelete(){ fileDelete(); } public static void fileDelete(){ Set<Id> contentDocumentIDs = new Set<Id>(); for(ContentDocument cd : (List<ContentDocument>)...


1

public with sharing class ContentDocumentLinkTriggerHandler { public static void fileCount(Trigger.new){ Set<Id> parentQuoteDocumentIds = new Set<Id>(); for(ContentDocumentLink cdl : Trigger.new){ parentQuoteDocumentIds.add(cdl.LinkedEntityId); You may want to do some filtering here, probably on cdl....


Top 50 recent answers are included