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
Sholunda Osby-BoardSholunda Osby-Board 

I am trying to write a validation rule to prevent the stages of an opportunity from being changed if certain cycle time fields are blank. For example if date of request and date of approval are blank; stage can not move from prospecting

Best Answer chosen by Sholunda Osby-Board
Arpit Jain7Arpit Jain7
Please try below validation rule

AND(OR(ISBLANK( date_of_Request__c ), IsBlank( Date_Of_Approval__c )), ISPICKVAL(PRIORVALUE(StageName),"Prospecting"), ISCHANGED( StageName ) )

I think it should work. Let me know for any issues.

Thanks 
Arpit

 

All Answers

Prafull G.Prafull G.
Yes. validation rule will be able to achieve this. Something like
AND(ISBLANK(APPROVAL DATE)), AND(REQUEST DATE), ISPICKVAL(PRIORVALUE(StageName), "Prospecting"), ISCHANGED(StageName))

Kindly check for syntax error and api name picklist values for your org.
Sholunda Osby-BoardSholunda Osby-Board
I am getting syntax errors. extra "," before the 2nd AND; when removed then extra "AND" on second "and" everytime I remove what is referred to as "extra" I get another syntax error
Arpit Jain7Arpit Jain7
Hi Sholunda,

Try below validation rule (Updatefield api name based on your date fields)

AND(ISBLANK( date_of_Request__c ), IsBlank( Date_Of_Approval__c ), ISPICKVAL(PRIORVALUE(StageName),"Prospecting"), ISCHANGED( StageName ) )

Let me know for any further concerns with this.

Mark this as solved if it helps.

Thanks
Arpit
Prafull G.Prafull G.
Thanks Aprit. Sholunda - as I mentioned syntax error as I did type directly here. You should be good now with Arpit's rule.
Sholunda Osby-BoardSholunda Osby-Board
No syntax errors, but tested validation rule and it does not populate error. I mistated the need though. The dates being blank are OR instead of AND. I changed the operator to "OR" in the beginning of code but it makes the error generate when the stage is changed regardless if date fields are populated.
Arpit Jain7Arpit Jain7
Please try below validation rule

AND(OR(ISBLANK( date_of_Request__c ), IsBlank( Date_Of_Approval__c )), ISPICKVAL(PRIORVALUE(StageName),"Prospecting"), ISCHANGED( StageName ) )

I think it should work. Let me know for any issues.

Thanks 
Arpit

 
This was selected as the best answer
Sholunda Osby-BoardSholunda Osby-Board
This one worked. One more question. How would I add option for picklist field to be blank in the validation rule?
Arpit Jain7Arpit Jain7
Try below to check blank picklist field

ISBLANK(TEXT(StageName ))

Mark this as solved if it helps.

Thanks
Arpit
Sholunda Osby-BoardSholunda Osby-Board
Thank you so much. Mission complete.
Sholunda Osby-BoardSholunda Osby-Board
This is not picking up a blank picklist field(Ultimate Risk Approver). What could be the issue?

ISBLANK(TEXT( Ultimate_Risk_Approver__c)),