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
Ricky 007Ricky 007 

how do we ensure that every account has unique shipping address?

Hi,
I am new to salesforce, i am facing an issue to make shipping address unique of every account so that no account has duplicate shipping records.
How to write a trigger for it, and also a warning messsage before saving record if duplicate found.
and if it could be achieve through validation rules or process builder then how i should i do this?
 
Best Answer chosen by Ricky 007
sowmya Inturi 9sowmya Inturi 9
Hi Ricky,
You can use Duplicate management rules to achive this. For this you need to create a matching rule first.
Matching Rule:
Setup--> Data.com Administration
-->Duplicate Management
-->Matching Rules (Click)
-->New
-->Select the object
--> Rule Name: "Unique Name matching rule" (of whatever it suites your needs)
--> Field: Name
--> Matching Method: Exact
-->Save/Activate

Duplicate Rule:
Setup--> Data.com Administration
-->Duplicate Management
-->Duplicate Rules (Click)
-->New Rule -->Select the object
-->Rule Name: "Unique Name" (of whatever it suites your needs)
-->Record-Level Security: Enforce sharing rules
-->Action on Create/Edit: Block
-->Compare Merchants With: <select your object>
-->Matching Rule: select the matching rules you have created in the STEP 1 -->Save/Activate

Let me know if you are facing any difficulties in creating this or if you want to create trigger only, I will help you out.


Thanks,
Sowmya.
 

All Answers

SandhyaSandhya (Salesforce Developers) 
Hi,

You  can use workflow and unique fields to create your own Salesforce duplicate record blocking tools.

Refer below blog whcih has the solution for similar requiement.

https://starrdata.com/preventing-salesforce-duplicates/
 
   Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 

 
sowmya Inturi 9sowmya Inturi 9
Hi Ricky,
You can use Duplicate management rules to achive this. For this you need to create a matching rule first.
Matching Rule:
Setup--> Data.com Administration
-->Duplicate Management
-->Matching Rules (Click)
-->New
-->Select the object
--> Rule Name: "Unique Name matching rule" (of whatever it suites your needs)
--> Field: Name
--> Matching Method: Exact
-->Save/Activate

Duplicate Rule:
Setup--> Data.com Administration
-->Duplicate Management
-->Duplicate Rules (Click)
-->New Rule -->Select the object
-->Rule Name: "Unique Name" (of whatever it suites your needs)
-->Record-Level Security: Enforce sharing rules
-->Action on Create/Edit: Block
-->Compare Merchants With: <select your object>
-->Matching Rule: select the matching rules you have created in the STEP 1 -->Save/Activate

Let me know if you are facing any difficulties in creating this or if you want to create trigger only, I will help you out.


Thanks,
Sowmya.
 
This was selected as the best answer
Ricky 007Ricky 007
Hi Sowmya,
Thanks for replying and for your efforts.
It works but to some extent, it is giving warning kind of message but still saving the record.
'We found 1 potential duplicate of this account' is showing after the record has been created.
Please help in creating trigger for the same or if this could be achieve through validation or process builder thats ok for me.

Thanks in advance.
sowmya Inturi 9sowmya Inturi 9
Hi Ricky,
Please select the picklist value for Action on Create and Action on Edit as 'Block'. It doesn't allow you to create the duplicate record.
User-added image

Let me know if this doesn't help you out. Will help you in creating a trigger.


Thanks,
Sowmya.
Ricky 007Ricky 007
Hi Sowmya,
Thanks for rectifying my mistake.
Really appreciates your efforts.