0

for example I have picklist on my custom object name CustomPicklist__c in this picklist I have all of language code this is huge list.

Can I make validation for save record, If one of picklist value is used you cannot save record with used value?

  • Basically, you have to validate that on existing records if any picklist value is used then we need to throw an error if the same value used for the new record. Is that correct? – Abhishek Daware Jan 31 '18 at 10:54
  • Yes, you have right – JJanek Jan 31 '18 at 10:57
  • Then validation rule won't solve the problem. – Abhishek Daware Jan 31 '18 at 10:59
  • You'll need to write Apex Trigger code for the same – RCS Jan 31 '18 at 11:02
0

Two solutions that can solve your problem

  1. Workflow Rule Create a text field 'UniqueLanguageCode' and mark as unique. Hide it from the page layout. Write a workflow rule whenever a picklist field value is edited then update the UniqueLanguageCode field.
  2. Before Trigger Write a before trigger to validate the existing records present with that picklist value. If exists then throw error else allow.

I will prefer the OOB solution.

  • I try make lower number of action via trigger and a lower fields on org. – JJanek Feb 1 '18 at 9:56
  • If you don't want to create an extra field on an object then go for the trigger. If above solutions solve your problem then mark this as the best answer. It might help others. – Abhishek Daware Feb 1 '18 at 11:18
  • Ok, If nobody paste better solution - I will mark this answear as the best. – JJanek Feb 1 '18 at 19:55
0

$User.Allow_Managed_Services_Case_Type__c = False && NOT (ISPICKVAL(Case_Type__c, "Managed Services Enquiry"))

Try this

  • 2
    Please add some explanation, not just a code dump. Also, adding custom fields to the User object for validation is horrible practice. Use Custom Permissions instead. – Adrian Larson Jan 31 '18 at 13:42
  • For me this is really bad because I have a lot of picklist values 50+ – JJanek Feb 1 '18 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.