0

Text_ID__c - text field with id of an Opportunity

A_Opportunity__c - lookup field to Opportunity

Both fields are in standard Account object. How can I populate the lookup field with the id in the text field? Will not work with workflow or process builder, guess I need Apex trigger (with which I have little experience). Can anyone provide code for this to at least put me on the right track? Would greatly appreciate it :)

  • Can you share your flow? I believe process builder + flow will allow this, as I've done so before – James Oct 28 '15 at 14:47
  • Hi James. The flow only allows to copy ID from a lookup field to another lookup field. Since my ID is in a text field, it is not giving me the option to reference it in the record update. – RA247 Oct 29 '15 at 15:35
  • Ah, makes sense. a workaround would be to use the lookup (text field) to query an object for the Id. From here, you can assign to your lookup field using flows/process – James Oct 30 '15 at 12:32
0

Something like this?

    trigger AccountTrigger on Account (before update,before insert) {
         for(account a : Trigger.New)
        {
            a.lookupField__c = a.FieldWithID__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.