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
IZavalunIZavalun 

PLEASE HELP WITH S-CONTROL SYNTAX....

Please Help....
I am getting the error "object expected" on line in red. What I have to do to fix it?
 
====================================================
<html>
<head>
<script src="/soap/ajax/9.0/connection.js"></script>
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script language="javascript">
function do_code()
{
sforceClient.init("{!API.Session_ID}", "{!API.Partner_Server_URL_70}", false);
var accountid = "{!TH_Distributor_Recap__c.DistributorId__c}";
var thdist = "{!TH_Distributor_Recap__c.Id}";
var qrdr = sforce.connection.query("Select BillingStreet, BillingCity, BillingState, Distributor_Type__c from Account where id = '" + accountid + "'");        
var records = qrdr.getArray("records");
alert(records.length);
alert(thdist);
for (var i = 0; i < records.length; i++)
{
tt = records[i];
var BillingStreet=tt.get("BillingStreet");
var BillingCity = tt.get("BillingCity");
var BillingState= tt.get("BillingState");
var Distributor_Type__c= tt.get("Distributor_Type__c");
}
alert(BillingStreet);
alert(BillingCity);
alert(BillingState);
alert(Distributor_Type__c);
///////////////////// update item//////////////////////////////////////////////
var thUpdate = new Array();
alert("1 - So far so good");
var thObject = new sforce.DynaBean("TH_Distributor_Recap__c");
alert("2 - So far so good");
thObject.set("Id", thdist);
thObject.set("Distributor_Address__c", BillingStreet);
thObject.set("Distributor_City__c", BillingCity);
thObject.set("Distributor_State__c", BillingState);
thObject.set("Distributor_Type__c", Distributor_Type__c);
thUpdate.push(thObject);
var update = sforceClient.Update(thUpdate);
parent.location.href = "{!TH_Distributor_Recap__c.Link}";
//////////////////////////////////////////////////////////////////////////////////////////
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body onLoad="do_code();">
</body>
</html>
cheenathcheenath
var thObject = new sforce.DynaBean("TH_Distributor_Recap__c");

This should be:

var thObject = new sforce.SObject(
"TH_Distributor_Recap__c");


var update = sforceClient.Update(thUpdate);

Instead of the above line, use:

var update = sforce.connection.update(thUpdate);



IZavalunIZavalun

Thanks a lot!!!!!

You are exactly right. I found the sample yesterday and when I updated the line in red with what you sugest it WORKS !!!!