+ Start a Discussion
Rung41Rung41 

Unexpected Token Else

For some reason I keep getting the error "Unexpected Token Else" and I can't figure out why.

If(
{!Model_Promo_Request__c.Model_Promo_Criteria_Validation__c} == TRUE)
{
window.open('{!URLFOR($Action.Model_Promo_Request__c.Submit,Model_Promo_Request__c.Id)}');
}
else{ 
alert('Your request is missing information required for approval.');
}
Best Answer chosen by Rung41
Raj VakatiRaj Vakati
Code is here
 
{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/42.0/apex.js")} 
 
if('{!Model_Promo_Request__c.Model_Promo_Criteria_Validation__c}'){
window.open('{!URLFOR($Action.Model_Promo_Request__c.Submit,Model_Promo_Request__c.Id)}');
}else{
alert('Your request is missing information required for approval.');

}

 

All Answers

Raj VakatiRaj Vakati
If({!Model_Promo_Request__c.Model_Promo_Criteria_Validation__c})
{
window.open("{!URLFOR($Action.Model_Promo_Request__c.Edit, Model_Promo_Request__c.id)}")
}
else{ 
alert('Your request is missing information required for approval.');
}

 
Rung41Rung41
I'm getting the same error :(
 
Raj VakatiRaj Vakati
Can you share the complete code 
Rung41Rung41
That is the complete code. I am trying to create a custom button with OnClick Javascript behavior. I take it I'm missing some required code???
Raj VakatiRaj Vakati
Code is here
 
{!REQUIRESCRIPT("/soap/ajax/42.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/42.0/apex.js")} 
 
if('{!Model_Promo_Request__c.Model_Promo_Criteria_Validation__c}'){
window.open('{!URLFOR($Action.Model_Promo_Request__c.Submit,Model_Promo_Request__c.Id)}');
}else{
alert('Your request is missing information required for approval.');

}

 
This was selected as the best answer
Rung41Rung41
Thank you!
Karen Roscoe - Administrator SFDCKaren Roscoe - Administrator SFDC
Hello, I'm trying to use Lightning Experience Configuration Converter to convert a Javascript button to a Lightning Component (Full). I keep getting the error " ESLINT_ERROR: {c:LCC_f42_Line_Configurator - CONTROLLER} line:col [8:1] Parsing error: Unexpected token else." The code is:

<aura:component extends="c:LCC_GenericLightningComponent" > <aura:handler event="c:LCC_GenericApplicationEvent" action="{!c.execute}"/> <aura:set attribute="partially" value="false"></aura:set> <aura:attribute name="showAlert" type="Boolean" default="false"/> <aura:attribute name="alertText" type="String"/> <aura:set attribute="isAdditionalObject" value="false"></aura:set> <div> <div class="slds-scrollable slds-p-around_medium slds-text-heading_small" id="modal-content-id-1"> <aura:if isTrue="{!v.showAlert}"> <p class="slds-hyphenate">{!v.alertText}</p> <aura:set attribute="else"> <div style="height: 6.75rem;"> <div role="status" class="slds-spinner slds-spinner_large slds-spinner_brand"> <span class="slds-assistive-text">Loading</span> <div class="slds-spinner__dot-a"></div> <div class="slds-spinner__dot-b"></div> </div> </div> </aura:set> </aura:if> <br/> </div> <footer class="slds-modal__footer"> <lightning:button class="slds-button_brand" onclick="{!c.accept}" label="Accept"/> </footer> </div> </aura:component>

What do I need to do? Thanks!