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
CushtyCushty 

Salesforce custom button validation rule

If statement on custom button syntax

Hi,
I am trying to do some validaton checks on some fields via a custom button and am getting stuck on a number field.  Basically I want to check.....does an opportunity type = Tender, the final price is less than 100,000 and the sharepoing link is blank  Here is the code: -

if({!ISPICKVAL(Opportunity.Opportunity_Type__c, "Tender")} && '{!Opportunity.Final_Price_Number__c}' > "100,000.00" && '{!Opportunity.Final_Pricing_Sharepoint_Link__c}' == "") {
     alert('You need to enter the Final Pricing Sharepoint URL for this Tender before submitting for approval');

The final price field is a number field and I think its this thats not working.  I am getting the error message all the time when I only need it when the figure typed in is less than 100,000

Thanks
 
Best Answer chosen by Cushty
JethaJetha
Ok, Please try below, you might have done some mistake,
 
if({!ISPICKVAL(Opportunity.Opportunity_Type__c , "Tender") && Opportunity.Final_Price_Number__c > 100000 && Opportunity.Final_Pricing_Sharepoint_Link__c == ""})
{
alert('You need to enter the Final Pricing Sharepoint URL for this Tender before submitting for approval');
}
else
{
alert('In Else');
}

Let me know if that resolve your issue.

All Answers

JethaJetha
Hi Cushty,

Please replace your code with below. It will work.
 
if({!ISPICKVAL(Opportunity.Opportunity_Type__c , "Tender") && Opportunity.Amount > 100,000.00 && Opportunity.Final_Pricing_Sharepoint_Link__c == ""})
{
alert('You need to enter the Final Pricing Sharepoint URL for this Tender before submitting for approval');
}
else
{
alert('In Else');
}

Please let me know if you face any issue.
CushtyCushty
Hi,
I get an error missing }
JethaJetha
Ok, Please try below, you might have done some mistake,
 
if({!ISPICKVAL(Opportunity.Opportunity_Type__c , "Tender") && Opportunity.Final_Price_Number__c > 100000 && Opportunity.Final_Pricing_Sharepoint_Link__c == ""})
{
alert('You need to enter the Final Pricing Sharepoint URL for this Tender before submitting for approval');
}
else
{
alert('In Else');
}

Let me know if that resolve your issue.
This was selected as the best answer
CushtyCushty
Thanks for your help, I had a similar rule below this one which once adjusted worked great