0

I've a requirement on pick-list field that field can allow to insert a value for first time and if the user try to insert a value second time that should through an error message.how can i achieve this.

4
  • I would say create a hidden checkbox and on the first update - write a WF to check the checkbox and now write a validation something like - AND( ISCHANGED(picklist), Checkbox)
    – Sanjay
    Sep 14, 2015 at 15:51
  • If you are talking about updating the picklist just use ISCHANGED(), ISCHANGED wont fire on insert. you cannot insert the value second time, your second time insert is technically an update unless you are talking about deleting the record and reinserting again.
    – Rao
    Sep 14, 2015 at 15:54
  • Hi Sanjay,thanks for quick reply.Can't we achieve this without Workflows?
    – User1511
    Sep 14, 2015 at 15:57
  • I think what @Rao mentioned makes sence, since ISCHANGED() wont fire on the intial insert and only fires on an update on the picklist. It should work try ISCHANGED(Picklist__c) as the validation criteria and test.
    – Sanjay
    Sep 14, 2015 at 16:09

1 Answer 1

1

You would need to check the PriorValue of the field along with IsChanged so that as long as the picklist value remains blank, i.e., the picklist value is not selected the first time, the system will allow the record to update the picklist value. But if the picklist value has been set, i.e., it is no longer blank, then the validation rule throw up an error.

Assuming the name of the field is Type, the following validation rule should work.

AND( 
    NOT(ISBLANK(PRIORVALUE(Type))), 
    ISCHANGED(Type) 
)

Based on your comment, added the condition to check for profile.

AND(
    NOT(ISBLANK(PRIORVALUE(Type))), 
    ISCHANGED(Type),
    NOT( $Profile.Name = 'System Administrator')
)
3
  • One doubt,Is there any possibility that only System Admin can edit this field for second time after using this Validation rule?
    – User1511
    Sep 14, 2015 at 18:51
  • @User1511, Have updated my answer to exclude the system admin from the validation rule.
    – Aayush K
    Sep 14, 2015 at 18:56
  • Hey Thanks Man,you are awesome.Its working as expected.
    – User1511
    Sep 14, 2015 at 19:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .