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
sowmya_umeshsowmya_umesh 

Prevent duplicate lookup field on custom object

Hello All,

I have a custom object, which has a lookup to case. I want unique case to be added to the custom object. I tried duplicate rules, matching rules, VLOOKUP, I was not able to get with these ways. Isthere any other way to achieve without coding?

Thanks.
Best Answer chosen by sowmya_umesh
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sowmya,

Greetings to you!

You can achieve this one by creating a Text(unique) field and a workflow rule.

1. Create a Text field (Unique) on Custom Object. Make sure to check unique checkbox while creating a text field.

2. Create a workflow rule with below things
    Evaluation Criteria:   created, and every time it’s edited
    Rule Criteria: Criteria are met 
    Record: Created Date Not Equal to Null

3. Add a workflow field Update Action
    In action insert/update new Text field with lookup field which is related to        Case Object.

Actually, we have created Text field for unique values, whenever we create/update custom object records, caseId will store in our custom Text field, If you select the same case second time it will throw an error.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Sowmya,

Greetings to you!

You can achieve this one by creating a Text(unique) field and a workflow rule.

1. Create a Text field (Unique) on Custom Object. Make sure to check unique checkbox while creating a text field.

2. Create a workflow rule with below things
    Evaluation Criteria:   created, and every time it’s edited
    Rule Criteria: Criteria are met 
    Record: Created Date Not Equal to Null

3. Add a workflow field Update Action
    In action insert/update new Text field with lookup field which is related to        Case Object.

Actually, we have created Text field for unique values, whenever we create/update custom object records, caseId will store in our custom Text field, If you select the same case second time it will throw an error.

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
sowmya_umeshsowmya_umesh
Thank you. It worked.