function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vital AzaVital Aza 

Automation: how update the current record with the value of a related (lookup) record, at record creation time

I am importing Contact records with Data Loader:
at record insertion, if AccountId (not required) is null then look up the Id of the related Account based on its AccountNumber, which is provided in the csv as an extra field.

I know this sounds like a Flow, but what type, formula, general logic?

Thank you.
Best Answer chosen by Vital Aza
Bennyp12Bennyp12
I would also add. You should add an additional step to verify that your AccountNumber did infact return a record. So another decision element to check if AccountID is null. This would allow you to apply another set of logic if no account is found with the account number for some reason.

All Answers

Bennyp12Bennyp12
Hello,

I think you can achieve this with a record triggered flow. 

Trigger on Contact Create>Use decision element to check if AccountId is NULL>IF Yes, fetch the Account record using the Get element>Finally, use the 'Update triggering record' element to update your accountID.

When I run an import like this I adjust my dataloader batch size to 100. It would also be worth running a small batch to test your automation. Ideally in a sandbox environment.
Bennyp12Bennyp12
I would also add. You should add an additional step to verify that your AccountNumber did infact return a record. So another decision element to check if AccountID is null. This would allow you to apply another set of logic if no account is found with the account number for some reason.
This was selected as the best answer
Vital AzaVital Aza
Thank you! I know realize how I need to contruct the flow. The one thing on which I am not clear is: how will Data Loader "send over" the AccountNumber from the CSV for the Flow to figure out the corresponding AccountId? Use an unused Contact field? Create a custom Contact field?? (ugh)

Please let me know your thoughts. I am just getting started with Flows and don't know all their capabilities.