You need to sign in to do that
Don't have an account?

Creating a custom button to execute Javascript
We have a managed CPQ package installed which has a button that performs a status change on the quote. I've copied the code and created a button to change the quote to a different status. The button works and changes the status to what I want, however, the error message in the "else" condition is showing what the error message is for the button that I copied the code from, which is irrelevant to my button. I want to change this, but if I do an edit in the button code I get a syntax error saying "field does not exist." This is the executed code:
{!requireScript("/soap/ajax/29.0/connection.js")}
var quoteId = "{!CPQ__Quote__c.CPQ__SalesforceId__c}";
var status = "{!CPQ__Quote__c.CPQ__Status__c}";
var statusToDraft = "Draft";
if(status == "Ready"){
var namespaceprefix = "{!$Setup.CPQ__HierarchicalProperty__c.CPQ__CPQ_Namespace__c}";
window.top.location = "{!$Site.Prefix}" + "/apex/" + namespaceprefix + "UpdateQuoteLifeCycle?quoteStatus="+ statusToDraft + ""eId=" + quoteId;
}else
{var markAsOrderedNotAllowed = "{!$Label.CPQ__QuoteMarkAsOrderedNotAllowed}";
alert(markAsOrderedNotAllowed);
}
The bolded part is what I need to change but can't figure out where !$Label.CPQ__QuoteMarkAsOrderedNotAllowed is coming from to change it. I am trying to change the quote status to Draft, but my code is based on "Mark As Ordered" which doesn't make sense. Any ideas?
{!requireScript("/soap/ajax/29.0/connection.js")}
var quoteId = "{!CPQ__Quote__c.CPQ__SalesforceId__c}";
var status = "{!CPQ__Quote__c.CPQ__Status__c}";
var statusToDraft = "Draft";
if(status == "Ready"){
var namespaceprefix = "{!$Setup.CPQ__HierarchicalProperty__c.CPQ__CPQ_Namespace__c}";
window.top.location = "{!$Site.Prefix}" + "/apex/" + namespaceprefix + "UpdateQuoteLifeCycle?quoteStatus="+ statusToDraft + ""eId=" + quoteId;
}else
{var markAsOrderedNotAllowed = "{!$Label.CPQ__QuoteMarkAsOrderedNotAllowed}";
alert(markAsOrderedNotAllowed);
}
The bolded part is what I need to change but can't figure out where !$Label.CPQ__QuoteMarkAsOrderedNotAllowed is coming from to change it. I am trying to change the quote status to Draft, but my code is based on "Mark As Ordered" which doesn't make sense. Any ideas?
- Create a new Custom Label and use it, you could put text accordinly to your need in it. Then use that new custom label in your button's jave script. Say Name of your custom label is "MyQuoteMarkAsOrderedNotAllowed" so your code will be var markAsOrderedNotAllowed = "{!$Label.MyQuoteMarkAsOrderedNotAllowed}";
- You could use translation workbench to update text of CPQ__QuoteMarkAsOrderedNotAllowed , You have to do English to English translation.
ThanksShashikant
All Answers
- Create a new Custom Label and use it, you could put text accordinly to your need in it. Then use that new custom label in your button's jave script. Say Name of your custom label is "MyQuoteMarkAsOrderedNotAllowed" so your code will be var markAsOrderedNotAllowed = "{!$Label.MyQuoteMarkAsOrderedNotAllowed}";
- You could use translation workbench to update text of CPQ__QuoteMarkAsOrderedNotAllowed , You have to do English to English translation.
ThanksShashikant