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
bobby-ncbobby-nc 

Need help with inserting new record in custom object...

Hi, I am trying to create an s-control that will create a new quote, which is a custom object, and populate certain fields with values from an existing opportunity.  Whenever I run the s-control, I receive a javascript error: Expected ";".  Am I missing something?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head> 
<title>Add Quote</title>
<script type="text/javascript" src="/soap/ajax/11.0/connection.js"></script>
</head>
<body>
<script type="text/javascript"> 
var objQuote = new sforce.SObject("Quote__c");
//insert fields...
sforce.connection.create([objQuote]);
</script>
</body> 
</html>

 
bobby-ncbobby-nc
Okay, I've figured it out for the most part.  The problem has to do with the line highlighted in red.  Both field types are Currency(16, 2).  Can anyone see what I am doing wrong with that line?
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add Quote</title>
<script type="text/javascript" src="/soap/ajax/11.0/connection.js"></script>
</head>
<body>
<script type="text/javascript">
var objQuote = new sforce.SObject("Quote__c");
objQuote.Opportunity__c = "{!Opportunity.Id}";
objQuote.Sale_Price__c = parseFloat("{!Opportunity.Pre_Sale_Price__c}");
objQuote.Margin__c = {!Opportunity.Pre_Sale_Margin__c};
try {
 result = sforce.connection.create([objQuote]);
}
catch(error) {
 alert("ERROR: " + error);
}
if (result[0].getBoolean("success")) {
 alert("It's ALL Good.");
}
else {
 alert("ERROR: " + result[0]);
}

</script>
</body>
</html>

 


Message Edited by bobby-nc on 02-29-2008 09:07 AM

Message Edited by bobby-nc on 02-29-2008 09:22 AM

Message Edited by bobby-nc on 02-29-2008 09:22 AM

Message Edited by bobby-nc on 02-29-2008 09:23 AM