+ Start a Discussion
nkbk0108nkbk0108 

JavaScript Help

Hi
We have Salesforce CPQ and at the time of implementation we had assistance from a consultant and developers to help us create a lot of the processes and buttons. We have one button right now that is no longer working and neither I or our the other Admin can figure out why this has stopped working.
What is supposed to do is prevent certain profiles from change the Status field on the Quote. If the Status is Custom Quote Requested and they click the Back to Draft button (code below) they would get an error. Right now it allows the status to be changed to Draft

{!REQUIRESCRIPT("/soap/ajax/52.0/connection.js")}

if("{!$Profile.Name}" == "System Administrator" ||
"{!$Profile.Name}" == "Contracts/Legal" ||
"{!$Profile.Name}" == "Field Sales AE, AM, CSM (Sales)" ||
"{!$Profile.Name}" == "Business Development (Sales)" ||
"{!$Profile.Name}" == "Channel Online (Sales)" ||
"{!$Profile.Name}" == "Client Service (Sales)" ||
"{!$Profile.Name}" == "Inside Sales AEs" ||
"{!$Profile.Name}" == "Sales Channel Tech & Financial" ||
"{!$Profile.Name}" == "Reseller (Sales)" ||
"{!$Profile.Name}" == "Sales Operations" ||
"{!$Profile.Name}" == "Sales Operations II" ||
"{!$Profile.Name}" == "Production Coordinator" ||
"{!$Profile.Name}'" == "Production Manager" ||
"{!SBQQ__Quote__c.SBQQ__Status__c}" == "Custom Quote Completed" ||
"{!SBQQ__Quote__c.SBQQ__Status__c}" == "Custom Quote Rejected" ||
"{!SBQQ__Quote__c.SBQQ__Status__c}" == "Approved" ||
"{!SBQQ__Quote__c.SBQQ__Status__c}" == "Rejected")
{
var quote = new sforce.SObject("SBQQ__Quote__c");
quote.Id = "{!SBQQ__Quote__c.Id}"; //Setting the ID of the Current Quote Record
quote.SBQQ__Status__c = "Draft"; //Setting the Status Picklist to Draft
var resultQuote = sforce.connection.update([quote]); //Updating the Quote Record
javascript: document.location.reload(true);
}
else
{
alert("Quote cannot be set Back to Draft from Custom Quote Requested status - contact your DDS Consultant.");
}
DescriptionSets the Status back to Draft, once the Quote meets certain criteria
ShivankurShivankur (Salesforce Developers) 
Hi There,

Please post the error line which you see while working with this button, so that community could help you specific to the point in your implementation.

Also, try to narrow down the conditions likewise remove everything first and then add the profiles one by one and this way you can captured where the access is being left, since the whole logic seems to be OR'ed and if any of the value is true then it proceeds with the operation.

Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.