You need to sign in to do that
Don't have an account?
ashish rai
How to get the Index of Picklist inside the formula???
Hi All,
Is there any way to get the index of picklist inside the validation rule???? I have a picklist having value a,b,c,d . So if i have selected c as picklist value next time when i update this record with picklist value as a,b it will through an error since this value is less in indexing(for example index of a is 1,b is 2 , c is 3 and d is 4). I can update the value of pickist which having greter than equal index value then existing.
Hi Ashish,
Am not really sure if this works but,
if the picklist values are alphabetically sorted,
have you tried directly using this condition
PRIORVALUE(picklist)>picklist then throw the validation error.
hope this helps ,
sidz
To my knowledge, you cannot do this using a validation rule. You'll need a trigger!
if(trigger.isBefore && trigger.isUpdate){
for(Object o:trigger.new{
newValue = o.picklist__c;
oldValue = Trigger.oldMap.get(o.Id).picklist__c;
if(newValue<oldValue){
o.addError('You cannot change the value of picklist to a smaller value');
}
}
}
Hope this should help!!
Hi,
I don't want this should be sorted alphabeticaly. I want it should give me the index in that order in which i have written inside the picklist. Any idea on this?????
Hi Ashish,
a little modification to the solution provided by force,
Hope this helps,
Sidz
(please mark this as the solution if it works for you )