• Samir Shaikh7
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
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
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