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
nkbk0108nkbk0108 

CPQ - Help with Javascript on button

Hi
We are having an issue with the Submit For Approval button we had created for our CPQ Quotes. We have a rule that you can't submit a quote under $250.00. This was working fine until we found out there is a rounding issue with some of the quotes and we end up with quotes totaling $0.01. We have tried to update the code to allow for up to $0.05 but we still run into the error. Would someone be able to review the code below and let us know what needs to change? Thanks in Advance :)
Nancy 

//IF is_custom == "0" and Net_Total < 250 and Net_Total != .05 
// alert("Cannot submit for approval quotes under $250.00") 

{!REQUIRESCRIPT('/soap/ajax/40.0/connection.js')} 

//Remove $ sign from currency field 
var netAmount = '{!SBQQ__Quote__c.SBQQ__NetAmount__c}'; 
var actualValue = netAmount.substr(1, netAmount.length-1); 

if ( actualValue <250.00 && actualValue != 0.5 ){ 
//Display message 
alert("Cannot submit for approval quotes under $250.00"); 
} else 

if ('{!SBQQ__Quote__c.Is_Custom__c}' == "1" && '{!SBQQ__Quote__c.SBQQ__Status__c}' != "Custom Quote Approved" ){ 
//Display message 
alert("Cannot submit for approval unless the Quote is in Custom Quote Completed Status."); 
} else 

if ('{!SBQQ__Quote__c.Quote_requires_Approval__c}' == "0"){ 
//Retrieve Record Type Id 
var recordtype= sforce.connection.query("SELECT id, name FROM recordtype WHERE SobjectType = 'SBQQ__Quote__c' AND name='Approved'"); 
var records = recordtype.getArray("records"); 

//Create quote to update 
var quote = new sforce.SObject("SBQQ__Quote__c"); 
quote.Id = '{!SBQQ__Quote__c.Id}'; //ID of the Current Quote Record 
quote.SBQQ__Status__c = "Approved"; //Setting Status Picklist to Approved 
quote.RecordTypeId = records[0].Id;//'01234000000475IAAQ'; //Setting RecordType to "Approved" 

//Update quote 
var result = sforce.connection.update([quote]); //Updating the Quote Record 
var isSuccess = result[0].getBoolean("success"); 

//Display error or success message 
if (!isSuccess) { 
alert(result[0].get("errors").get("message")); 
} else { 
alert("This quote does not require approval, so it will be automatically Approved.");


//Refresh page 
document.location.reload(true); 

} else { 

if (('{!SBQQ__Quote__c.Is_Custom__c}' == "0" && '{!SBQQ__Quote__c.SBQQ__Status__c}' == "Draft") || ('{!SBQQ__Quote__c.SBQQ__Status__c}' == "Custom Quote Approved" && '{!SBQQ__Quote__c.Is_Custom__c}' == "1" ) ) { 
//Submit the Quote for Approval 
var request = new sforce.ProcessSubmitRequest(); 
request.objectId = '{!SBQQ__Quote__c.Id}'; 
var processRes = sforce.connection.process([request]); 
location.reload(); 
} else { 
//Display error message 
alert("Cannot submit for approval unless the Quote is in Custom Quote Completed Status, or is in Draft Status and does not require a Custom Quote."); 

}