0

I have what I think is a very simple request, but I'm struggling with it.  I have a custom field on the Case object called Account ID, which is a text field.  I also have a field called Primary Account, which is a lookup field.  I have a Google form integration that creates a Case when a form is submitted and populates the Account ID with the 15-character Account ID, input by the form submitter.  I want to create a trigger to take that value and populate the Primary Account lookup field with the Account associated with the ID.  Can anyone point me to code that can accomplish this?  Thanks,

1

This is a simple trigger. You may need to adjust my code below to make it work. The Trigger.new Context Variable makes this super easy!

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm

trigger populateaccountlookup on Case (before insert) {

    for (Case i : Trigger.new) {
    i.primary_account__c = i.account_id__c;

    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.