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
John BraunJohn Braun 

How to place conditional logic within an onclick javascript custom button?

Hello!

 

If my subject wasn't clear enough, I'm trying to figure out how to place an "AND" statment within an IF statment that is used inside an Onclick Javascript custom button.

 

The desired actions of the button -

 

When clicked, and the opportunity.proposal number field is NOT NULL,

 

AND

 

opportunity.active revision is FALSE, then go to the below link:

 

'https://cs11.salesforce.com/a11/e?CF00NZ0000000rsGi={!Opportunity.Name}&CF00NZ0000000rsGi_lkid={!Opportunity.Id}&CF00NZ0000000rjg8={!Opportunity.Quote_Name__c}&00NZ0000000rk1B={!Opportunity.Proposal_Number__c}&retURL=/{!Opportunity.Id}'

 

If clicked, and the opportunity.proposal number field is BLANK, then display this error:

 

'You may only request a Quote Revision when there is an active Quote.',

 

If clicked, and the opportunity.proposal number field is NOT NULL,

 

AND

 

opportunity.active revision is TRUE, then display this error:

 

"The previous Revision has not yet been issued back to sales"

 

 

 

Below, you can see what I have so far. As you can see, I have not been able to figure out how to insert my conditional logic regarding the opportunity.active revision field. I thought if I understood how to place an "AND" statement, I could pull it off. I would greatly appreciate any help, thanks so much -

 

 

if ( '{!Opportunity.Proposal_Number__c}' != '')
{
window.location = 'https://cs11.salesforce.com/a11/e?CF00NZ0000000rsGi={!Opportunity.Name}&CF00NZ0000000rsGi_lkid={!Opportunity.Id}&CF00NZ0000000rjg8={!Opportunity.Quote_Name__c}&00NZ0000000rk1B={!Opportunity.Proposal_Number__c}&retURL=/{!Opportunity.Id}';
}
else
{
alert('You may only request a Quote Revision when there is an active Quote.');
}

John BraunJohn Braun

Hmmm,

I tried the below and it still doesn't work:

if ('{!Opportunity.Proposal_Number__c}' != '' && {!Opportunity.Active_Revision__c} == 'true') { 
alert("The previous Revision is still Active."); 


if ('{!Opportunity.Proposal_Number__c}' == '') 
{alert('You may only request a Quote Revision when there is an active Quote.'); 



else 

window.location = 'https://cs11.salesforce.com/a11/e?CF00NZ0000000rsGi={!Opportunity.Name}&CF00NZ0000000rsGi_lkid={!Opportunity.Id}&CF00NZ0000000rjg8={!Opportunity.Quote_Name__c}&00NZ0000000rk1B={!Opportunity.Proposal_Number__c}&retURL=/{!Opportunity.Id}'; 
}

John BraunJohn Braun
I figured it out, you don't put quotations around "true".