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
Anudeep BAnudeep B 

Restrict the Duplicates to Entering through Dependent Picklist.!

I created a custom Object "Location" , all are 3 picklists and each other dependent picklists hirarchely.  

User-added image

I am getting Duplication entries from these fields.
when i select HeadQuarter there can be multiple Areas should be enter but once i select one Area in one HeadQuarter,
the selected Area should not save again in the record .

To avoid this which criteria should i follow,

Workflow
Validation Rule
Trigger

Which one is suitable and how.

Is there any other Good Apporach .


 
Best Answer chosen by Anudeep B
Chidambar ReddyChidambar Reddy
Hi Anudeep,

You can use an UNIQUE text field and update it through workflow, by this you can avoid duplicate records

Create a text field as Unique field
Create a workflow to update this field when created and everytime edited
update the field with 'HeadQuarter__c+Area__c'

Thanks

All Answers

Chidambar ReddyChidambar Reddy
Hi Anudeep,

You can use an UNIQUE text field and update it through workflow, by this you can avoid duplicate records

Create a text field as Unique field
Create a workflow to update this field when created and everytime edited
update the field with 'HeadQuarter__c+Area__c'

Thanks
This was selected as the best answer
Anudeep BAnudeep B
Thank You Mr. Chidambar Reddy,

You not getting my point i think so.

From the above image those picklists are Dependent picklists, so when i select HeadQuarter it will contain the related Areas in Area Picklist Field.

So here my requirement is 

Ex:   Karimnagar --------> HeadQuarter
        Areas (Picklist):  Ramagundam
                                 Peddapally
                                 Huzurabad
                                 Kamalapur etc...


now i select Karimnagar and Ramagundam, and Save the record.
                  Karimnagar and Peddapally and Save the record.
                  Karimnagar and Huzurabad and Save the record.
                  Karimnagar and Ramangundam and Save the record -------- This record i don't want to Save again, for that what is the solution.



Awaiting for your Answer.
Thank You.
Chidambar ReddyChidambar Reddy
Yes I understood it my dear friend,

try the suggested process

as unique field do not allow duplicate values it throws error before saving the record

if Karimnagar and Ramagundam are chosen for record, the unique field will be updated as 'KarimnagarRamagundam' if you follow the suggested process

so if you try to create a new record with same values, it will stop you with an error
Anudeep BAnudeep B
Are there write now, Could you please navigate me how to do this, i am not getting idea how to make unique for picklist values.

please catch me on abatini27@gmail.com i am online now.
Chidambar ReddyChidambar Reddy

Go to custom fields of that object
Click new 
Select text data type and proceed by providing some label and name for it and choose unique check box there case insensitive 
Go to workflow rules create new 
And choose the object
Give some name choose 
Created and every time its edited
Entry criteria if formula 
And type TRUE in the formula editor
Click next
Choose a workflow action and create a field update
Choose the unique filed you have created
Choose the formula editor 
There enter your first picklist api name and add + symbol then add you second picklist api name 
Save it 
Activate the workflow
Enjoy 😊
 
Anoop yadavAnoop yadav
Hi,
If you want to write the Trigger, Refer the below link and change accordingly.
http://developer.force.com/cookbook/recipe/preventing-duplicate-records-from-saving