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
Marco JanmaatMarco Janmaat 

validation rule that checks status of synchronized quote

"m trying to write a validation rule whereby when the user closes the opportunity, it checks if a quotation is synchronized and if the status of the quotation is accepted or rejected. Somehow I cannot get it to work. Below my code


AND(CASE(StageName,"Closed Won",1,"Closed Lost",1,0 ) =1, ISBLANK(SyncedQuote.Id), ISPICKVAL(SyncedQuote.Status,"Accepted"), ISPICKVAL(SyncedQuote.Status,"Rejected") )
Best Answer chosen by Marco Janmaat
Maharajan CMaharajan C
Ok Got it...

Please use the below formula:
 
AND(
CASE(StageName,"Closed Won",1,"Closed Lost",1,0 ) =1,
OR(
ISBLANK(SyncedQuote.Id),
AND(
NOT(ISBLANK(SyncedQuote.Id)),
NOT(ISPICKVAL(SyncedQuote.Status,"Accepted")),
NOT(ISPICKVAL(SyncedQuote.Status,"Rejected"))
)
)
)

Thanks,
Maharajan.C

All Answers

Maharajan CMaharajan C
Hi Janmaat,

Can you please explain more. Am not able to understand clearly.

Based on my understanding I have the below formula's. Please try it.

1. On Closing the Opportunity check there is any synced quote and If it is Accepted or Rejected status then throw the error:
AND(
	CASE(StageName,"Closed Won",1,"Closed Lost",1,0 ) =1, 
	NOT(ISBLANK(SyncedQuote.Id)), 
    OR(
	ISPICKVAL(SyncedQuote.Status,"Accepted"), 
	ISPICKVAL(SyncedQuote.Status,"Rejected"))
)

2. On Closing the Opportunity check there is any synced quote and If it is not Accepted or Rejected status then throw the error:
 
AND(
	CASE(StageName,"Closed Won",1,"Closed Lost",1,0 ) =1, 
	NOT(ISBLANK(SyncedQuote.Id)), 
    OR(
	NOT(ISPICKVAL(SyncedQuote.Status,"Accepted")), 
	NOT(ISPICKVAL(SyncedQuote.Status,"Rejected")))
)

Thanks,
Maharajan.C

 
Marco JanmaatMarco Janmaat
Hi Maharajan,

Thats indeed what I'm looking for.

I added your code under the validation rules of the Opportunity field.

However, it doesn't give any error. When I don't sync the quote it doesn't give a error. It simply accepts closing the opportunity without any error.
Somehow its not working. Any idea?

User-added image
Marco JanmaatMarco Janmaat
So maybe to further clarify:
When I close an opportunity I want it to check:

1) Does the opportunity have a synchronized quotation. If it has no synchronized quotation, It will show error message.

2) Is the status of synchronized quotation, "Accepted" or "Rejected". If its none of both, It will show error mesage.

The idea behind is that account manager firsts let us know if the "quotation" is accepted or rjected, before they close the opportunity .
 
Maharajan CMaharajan C
Ok Got it...

Please use the below formula:
 
AND(
CASE(StageName,"Closed Won",1,"Closed Lost",1,0 ) =1,
OR(
ISBLANK(SyncedQuote.Id),
AND(
NOT(ISBLANK(SyncedQuote.Id)),
NOT(ISPICKVAL(SyncedQuote.Status,"Accepted")),
NOT(ISPICKVAL(SyncedQuote.Status,"Rejected"))
)
)
)

Thanks,
Maharajan.C
This was selected as the best answer