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
Sachin Kumar 34Sachin Kumar 34 

New Contract will create Based on Button

I had added new button "Create Contract" in opportunity page now i want to set the functionality on this. Once user click on the button, the new contract will create and the field data will be transferred from Opportunity to a new contract. I had used the below script into the button, but getting an error.Opp Fields Need to transferError getting

Button Code:


var contract = new sforce.SObject('Contract');

contract.Net_License__c = '{!Opportunity.Net_License__c }';

contract.Net_Maintenance_Amount__c = '{!Opportunity.Maintenance_Amount__c}';

contract.Net_Consulting_Amount__c = '{!Opportunity.Services_Amount__c }';

contract.Net_Training_Amount__c = '{!Opportunity.Net_Training_Amount__c}';

contract.Deal_Total_cal__c = '{!Opportunity.P_Amount__c}';

contract.OppOpp__c = '{!Opportunity.Opportunity_No__c}';

result = sforce.connection.create([contract]);

if(result[0].success == 'true') { window.location = '/' + result[0].id ; } else { alert('Error');

Check your data type for those fields on Opptunity. Because it trying to convert "USD 2.00" to a double value, so it failed.
Try make the field only have "2.00" in it and you can put "USD " outside the field