You need to sign in to do that
Don't have an account?
Nick White
System.FinalException: Record is read-onlyTrigger
I have the following basic Trigger. This works well when opening a new or amending an existing record and saving.
trigger QuoteUpdateGPN2 on Quotation_Detail__c (before update) {
for (Quotation_Detail__c a : Trigger.new) {
if (a.GPN_Link__c == null) {
a.GPN_Link__c = [Select Id FROM Product2 Where Name =:a.Part_Number__c][0].Id;
}
}
}
Unfortunately it is not working as part of an "after insert" trigger, for when I upload data via Dataloader, as it indicated the field is Read Only.
I understand why, it is indicating as read only, as the field is active, but I am unable to solve.
How can I make this trigger work with "after insert", as well as "before update"
Many thanks
trigger QuoteUpdateGPN2 on Quotation_Detail__c (before update) {
for (Quotation_Detail__c a : Trigger.new) {
if (a.GPN_Link__c == null) {
a.GPN_Link__c = [Select Id FROM Product2 Where Name =:a.Part_Number__c][0].Id;
}
}
}
Unfortunately it is not working as part of an "after insert" trigger, for when I upload data via Dataloader, as it indicated the field is Read Only.
I understand why, it is indicating as read only, as the field is active, but I am unable to solve.
How can I make this trigger work with "after insert", as well as "before update"
Many thanks
All Answers