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
SriniSrini 

Help_Validation rule

Hi Team,

Can any one please help me to create a Validationrule for below senario.
 
Is this approvedRequest #Approval Status
<Blank><Blank>Not Submitted
<Blank><Completed>Submitted for Approval
Yes<Completed>Approved
Yes<Blank>Not Submitted
No<Completed>Rejected
No<Blank>Not Submitted


Thanks in Advance
karthikeyan perumalkarthikeyan perumal
hello, 

Correct me if i am wrong, 

Is_this_approved__c field is Checck box, 
Request__c field is Text field
Approval_Status__c is picklist, 

if its not, let me know the field name with dataType

Thanks
karthik
 
SriniSrini
@Karthi,

Please check below Datatypes:

Is_this_approved__c =  Picklist(Yes,No)
Request__c = Text
Approval_Status__c = Picklist(Not Submitted,Submitted for Approval,Approved,Rejected)

Thanks
karthikeyan perumalkarthikeyan perumal
Hello, 

Use below code  in validation rule, 
 
AND( 
IF(ISPICKVAL(Is_this_approved__c, '') &&Request__c='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, '') &&Request__c='Completed' && ISPICKVAL(Approval_Status__c,'Submitted for Approval'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'Yes') &&Request__c='Completed' && ISPICKVAL(Approval_Status__c,'Approved'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'Yes') &&Request__c='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'No') &&Request__c='Completed' && ISPICKVAL(Approval_Status__c,'Rejected'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'No') &&Request__c='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True) 
)

Hope this will help you, 

Mark Best ANSWER if its work for you.. 

Thanks
karthik

 
SriniSrini
Hi Karthik,

Thanks for your helping to me..I have one doubt hear Request__c field Data type is "Text field" .After filling the one request form one number is genrated like "RN-123456"  that number we needs to be enetred in the Request__c field. In validation rule how we can mention instead of Request__c='Completed'  to  Request__c='RN-123456' .Can you please help me on this.


Thanks
karthikeyan perumalkarthikeyan perumal
Hello, 

Yes it will accept, use below code, for your change,
 
AND( 
IF(ISPICKVAL(Is_this_approved__c, '') &&Request__c='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, '') &&Request__c='RN-123456' && ISPICKVAL(Approval_Status__c,'Submitted for Approval'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'Yes') &&Request__c='RN-123456' && ISPICKVAL(Approval_Status__c,'Approved'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'Yes') &&Request__c='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'No') &&Request__c='RN-123456' && ISPICKVAL(Approval_Status__c,'Rejected'),False,True), 

IF(ISPICKVAL(Is_this_approved__c, 'No') &&Request__c='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True) 
)

Hope this will help

Thanks
karthik


 
SriniSrini
Hi Karthik.

Request field is always not same it will be changing  .We have tried below validatione rule.But not working.Please have a look on this issue.

AND 
(IF(ISPICKVAL(Is_this_approved__c ,'--None--') && Request__c ='' && ISPICKVAL(Approval_Status__c ,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'--None--') && Request__c <>'' && ISPICKVAL(Approval_Status__c,'Submitted for Approval'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'Yes') && Request__c <>'' && ISPICKVAL(Approval_Status__c,'Approved'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'Yes') && Request__c ='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'No') && Request__c <>'' && ISPICKVAL(Approval_Status__c,'Rejected'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'No') && Request__c ='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True))

Thanks




 
karthikeyan perumalkarthikeyan perumal
Hello, 

use this below code.. i checked in my org it will work 100% 
 
AND 
(IF(ISPICKVAL(Is_this_approved__c ,'--None--') && Request__c ='' && ISPICKVAL(Approval_Status__c ,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'--None--') && NOT(ISBLANK(Request__c)) && ISPICKVAL(Approval_Status__c,'Submitted for Approval'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'Yes') && NOT(ISBLANK(Request__c)) && ISPICKVAL(Approval_Status__c,'Approved'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'Yes') && Request__c ='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'No') && NOT(ISBLANK(Request__c)) && ISPICKVAL(Approval_Status__c,'Rejected'),False,True), 

IF(ISPICKVAL(Is_this_approved__c,'No') && Request__c ='' && ISPICKVAL(Approval_Status__c,'Not Submitted'),False,True))

Hope this will help you, 

Mark Best ANSWER  if its helps you. 

Thanks
karthik
 
SriniSrini
Hi Karthik,

Sorry for the late response..logic is not working me.Is there any possibilty to do through workflows? if yes can you please tell me how to do.

Thanks
Srini
 
karthikeyan perumalkarthikeyan perumal
Hello, 

Sorry, really i dont know what you want to do. you want a raise a validation error messgae to prevent save record or you want to field update based on the those 2 fields value? 

if you want to prevent record saving with validation you have to use validation rule. in this case my last updated validation rule works perfectly. 

OR 

if you want to update Approval Status field based on  those 2 fields. you should have to use workflow rule with field update or process builder 

 make things clear so that you can stick with one way. 

Thanks
karthik
 
SriniSrini
Hi Karthik,

Actually we are trying to
1.If Is this approved Field(Picklist) "Blank means None" , Nuclear Risk SC Request # field(every time it is not same number or trext) is "Empty(No value)" then Approval Status(Picklist) should be NotSubmitted.
2.If Is this approved Field,  Request  field is "RC-01234" then Approval Status should be Submitted for Approval.
3.If Is this approved Field "Yes" ,  Request  field is "RC-01235" then Approval Status should be Approved.
4.If Is this approved Field "Yes" , Request field is "Empty" then Approval Status should be Not Submitted.
5.If Is this approved Field "No" , Request field is "RC-01236" then Approval Status should be Rejected.
6.If Is this approved Field "No" , Request field is "Empty" then Approval Status should be Not Submitted.

Let say If i select "IsthisApproved" = Yes, Request  = some data (RC-01234) then Approval Status should be Approved. so hear we are updating the Approval Status field based on the IsthisApproved and  Request fields.similorly other points as well.. 

I hope whatever we have done so far logic is good.But that logic is not working me.Can you please help me to create workflow rules on this.

Thanks