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
JohnDuraiJohnDurai 

Making one primary contact for account using lightning flow

Hi - I have this scenario, One Account has multiple contacts and in Contact object we have field called Primary contact checkbox field.

If any one of the related contact  is true in  Primary contact checkbox field then other contacts shoud not have option to check that checkbox field.

How to do this lightning flow? can someone suggest ideas. Thanks
Best Answer chosen by JohnDurai
Sai PraveenSai Praveen (Salesforce Developers) 
Cont...

Adding the current record in loop to the variable created above:

User-added image
Updating the collection:

User-added image
Entire Flow:

User-added image

If this solution helps, please mark it as best answer.
If you have any doubts, Feel free to post the comment.


Thanks,
 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi John,

Your requirement is to have only one Contact record related to the Account should be primary and want it using Flows. 

This will work only if you create /Edit the contact and mark it primary then remaining all the contacts of account will be unchecked. If there are already records with two primary contacts system does not know which contact to consider as primary. Is that okay for the design?

Thanks,
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi John,

Please find the below record triggered flow on Contact object.

Start Element:

User-added imageGet contacts related to Account:
User-added imageFor Loop:

User-added image
Assigment element making primary contact to false:

User-added image
Create a resource of type variable of record of contact with multiple options:

User-added image
Continuation in next comment....

 
Sai PraveenSai Praveen (Salesforce Developers) 
Cont...

Adding the current record in loop to the variable created above:

User-added image
Updating the collection:

User-added image
Entire Flow:

User-added image

If this solution helps, please mark it as best answer.
If you have any doubts, Feel free to post the comment.


Thanks,
 
This was selected as the best answer
JohnDuraiJohnDurai
Thanks @Sai Praveen it works, but just want to confirm a quick thing here if they switch one primary contact to other shall me make some warning message stating that "already there is one primary contact available would you like to make it as primary something like that "and they can able to switch.
Philippe Recto 14Philippe Recto 14

Hello John and Sai. Thank you for posting this as I am also trying to make this exact Flow for my Org. However, a portion of your instruction was cut off. I was hoping to verify The detail on the "Get Record"

Under the Filter Contact Records, the first filter is cut off for the "Value" Please advise on what the value is? Thank you in Advance!

Get Records
Field: Account ID | Operator: Equals | Value: Account????

User-added image