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
Alper CekicAlper Cekic 

non working if statement on custom button

Hi,
I am trying to create a custom button with an if statement to use on a quote detail page. Sample code as follows;
{!IF
(
TEXT(Quote.Status)<>"Akzeptiert",
URLFOR("/apex/SalesFlowCreateOrderContract"),
'/flow/Quote_to_Order_with_Contract?QuoteID="{!Quote.Id}&"retURL=/"{!Quote.Id}'
)}

On the first option, the code tries to redirect to a VF page which works perfectly. But if statement continues on to the second option either I get encoding errors or non-working if statement depending on the syntax I tried to avoid errors. I tried to use URLENCODE but it did not work too.

Is there anyone who may share ideas on this?

thanks
Alper
 
RKSalesforceRKSalesforce
Hi Alper,

I think it is due to ! before if:

Please use below code: 
{if
(
TEXT(Quote.Status)<>"Akzeptiert",
URLFOR("/apex/SalesFlowCreateOrderContract"),
'/flow/Quote_to_Order_with_Contract?QuoteID="{!Quote.Id}&"retURL=/"{!Quote.Id}'
)}
Hope this will help. Please mark answer if helped.

Regards,
Ramakant
Alper CekicAlper Cekic
Hi Ramakat,

unfortunately removing the exclamation mark resulted printing the code in the URL instead of executing it.

 cmydomain.cs88.my.salesforce.com/servlet/%7Bif(TEXT(Quote.Status)%3C%3EAkzeptiert,URLFOR(/apex/SalesFlowCreateOrderContract),%27/flow/Quote_to_Order_with_Contract?QuoteID=0Q09E000000AyPi&retURL=/0Q09E000000AyPi%27)%7D

regards
Alper
 
Alper CekicAlper Cekic
Hi,

While playing around I found the solution, custom button code should be as follows;
 
{!if
(
TEXT(Quote.Status)<>"Akzeptiert",
URLFOR("/apex/SalesFlowCreateOrderContract"),
URLFOR('/flow/Quote_to_Order_with_Contract?'&'QuoteID='&Quote.Id
&
"&retURL="
&Quote.Id)
)}

cheers
Alper