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
Gadivemula KrishnaGadivemula Krishna 

what is prior value in Salesforce and how can we write ispickval and prior value?

I am newbie to Salesforce, I am trying to undertsand the ispickval and prior value. So any insights are helpful to learn for me. 

Thank you in Advance

Best Answer chosen by Gadivemula Krishna
mukesh guptamukesh gupta
Hi Krishna,

Line 1:- AND( ISNEW() ,Not ISPICKVAL(Account_type__c, 'Register') ):-
Your Record will be new and Account_type__c field value should not be Register

Line 2: AND( ISPICKVAL( PRIORVALUE(Account_type__c),'Register' ) , ISPICKVAL(Account_type__c, 'Gold') ) 
Account_type__c field  previous value 'Register' and  Current selected Account_type__c field value 'Gold'

For Example:-  Your record have Account_type__c field value 'Register' and now you are trying to Edit this field value to 'Gold' and click on save then Account_type__c field previous value will be  Register

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh


 

All Answers

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

PriorValue() is used to get the previous value of the field and ISPICKVAL() is used to get the value of the picklist field in formula and validation rule.

Please find the below article for the same,

https://www.oreilly.com/library/view/salesforce-advanced-administrator/9781838643898/7fd10169-049f-4492-8582-efd1d8506f7b.xhtml

let me know if you need any further details.

Please mark it as best answer. if this helps

Thanks,
 
Gadivemula KrishnaGadivemula Krishna
So Actually What I am trying to do is, I have a picklist called Account type(Gold, Silver and Register - These are the picklist values). So While creating the record in Account Object, There are some validation rules. 
1) Account record can only be created with Register type. 
2) One cannot direrctly edit to Register to Gold. 
3) It should be traverse from Register to Silver, And then Silver to Gold. 

I have tried ths code actually, Its working 
OR(
AND( ISNEW() ,Not ISPICKVAL(Account_type__c, 'Register') ),
AND( ISPICKVAL( PRIORVALUE(Account_type__c),'Register' ) , ISPICKVAL(Account_type__c, 'Gold') ) ,
AND( ISPICKVAL( PRIORVALUE(Account_type__c),'Silver' ) , ISPICKVAL(Account_type__c, 'Register') ) ,
AND( ISPICKVAL( PRIORVALUE(Account_type__c),'Gold' ) , ISPICKVAL(Account_type__c, 'Register') ),
AND( ISPICKVAL( PRIORVALUE(Account_type__c),'Gold' ) , ISPICKVAL(Account_type__c, 'Silver') )

)
But i am unable to understand what happening in the code as line to line. 
mukesh guptamukesh gupta
Hi Krishna,

Line 1:- AND( ISNEW() ,Not ISPICKVAL(Account_type__c, 'Register') ):-
Your Record will be new and Account_type__c field value should not be Register

Line 2: AND( ISPICKVAL( PRIORVALUE(Account_type__c),'Register' ) , ISPICKVAL(Account_type__c, 'Gold') ) 
Account_type__c field  previous value 'Register' and  Current selected Account_type__c field value 'Gold'

For Example:-  Your record have Account_type__c field value 'Register' and now you are trying to Edit this field value to 'Gold' and click on save then Account_type__c field previous value will be  Register

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh


 
This was selected as the best answer