0

i facing following issue:

We Have Obj. Account and Obj. B__c. On Object Account we have a ID__c which stores an ID. Now we get this ID from an external System written in an text field on Obj. B__c

Now i need a piece of code which matches teh ID from Obj. B__c with the ID from Account and if a match is found the LOOKUP on Obj. B__c should be populated with the ACCOUNT NAME which has the same ID.

I hope it is undersantable and anyone can help me out with some link for ressources.

Thank you.

Sebastian

1 Answer 1

0

In this case, you can write a trigger on B__C. I am not sure about the process builder though. Please find the below piece of code for reference. You can change it as per your needs.

trigger testTrig on B__c(before update) {

    set<string> setIds = new set<string>();
    Map<String,Id> mapMatch = new Map<String,Id>();
    for(B__c b : Trigger.New)
    {
        setIds.add(b.ID__c);

    }

    for(Account acc : [Select Id, ID__c from Account where ID__c IN : setIds])
    {
        mapMatch.put( acc.ID__c,acc.Id);

    }

    for(B__c b : Trigger.New)
    {
        if(mapMatch.containsKey(b.ID__c))
        {
           b.Account__c = mapMatch.get(b.ID__c); 
        }

    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .