0

I have a custom Javascript button on the OpportunityLineItem object that is a List button on the Opportunity. It's designed to take users to various edit pages for Opportunity products based upon the Opportunity record type. However, it only seems to take the user to the first page it selects, even when the record type is changed in the Opportunity and re-saved. Is there some type of "reset" code that needs to be included in the button?

if('{!Opportunity.Commitment_Type__c}' == 'Portfolio'){
if('{!CONTAINS(Opportunity.RecordTypeId,$Label.ENT_CommitRT_ID)}'){
    window.open('/apex/VF_opportunityProductEntry?id={!Opportunity.Id}') 
}
}
else if('{!CONTAINS(Opportunity.RecordTypeName_ENT__c,"Premier")}'){

if(window.location.href.indexOf("premierreseller") > -1){
window.open('/premierreseller/apex/opportunityProductEntry?id={!Opportunity.Id}')
}
else {
window.open('/apex/opportunityProductEntry?id={!Opportunity.Id}')
}
}

else if(window.location.href.indexOf("premierreseller") > -1){
    window.open('/premierreseller/p/opp/SelectSearch?addTo={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}')
}

else if('{!CONTAINS(Opportunity.RecordTypeId,$Label.ENT_ExclusiveRT_ID)}'){
window.open('/apex/opportunityProductEntry_Exclusive?id={!Opportunity.Id}')
}

else{
    window.open('/p/opp/SelectSearch?addTo={!Opportunity.Id}&retURL=%2F{!Opportunity.Id}')
}
1

Your first condition:

if('{!CONTAINS(Opportunity.RecordTypeId,$Label.ENT_CommitRT_ID)}')

Would end up evaluating to either if('true') or if('false') which are both truthy in Javascript. Try removing the single quotes from around the {!expression} when it's returning a boolean.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.