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
Kate StarostinaKate Starostina 

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 + "&quoteId=" + 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? 
Best Answer chosen by Kate Starostina
Shashikant SharmaShashikant Sharma
CPQ__QuoteMarkAsOrderedNotAllowed is a Custom Lable in the CPQ managed package that is installed in your org. You can not directly update it but there are two options for you.
  1. 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}";
  2. You could use translation workbench to update text of CPQ__QuoteMarkAsOrderedNotAllowed , You have to do English to English translation.
Thanks
Shashikant

All Answers

Shashikant SharmaShashikant Sharma
CPQ__QuoteMarkAsOrderedNotAllowed is a Custom Lable in the CPQ managed package that is installed in your org. You can not directly update it but there are two options for you.
  1. 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}";
  2. You could use translation workbench to update text of CPQ__QuoteMarkAsOrderedNotAllowed , You have to do English to English translation.
Thanks
Shashikant
This was selected as the best answer
Kate StarostinaKate Starostina
This is great thank you.  I thought it was a custom label but couldn't find it last night.  I found it this morning though!!!