+ Start a Discussion
wkuehlerwkuehler 

trouble with Dynabean

This S-Control is being called from a link on the account page.  All I want it to do is update the phone number to be "5555555".  Any help would be appreciated.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script src="http://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>

<script language="JavaScript1.2">
function updateaccountinfo()
{
 var updateObjects = new Array();
 var accountinfo = new Sforce.Dynabean("account");
 
 accountinfo.set("Id", "{!Account_ID}");
 accountinfo.set("Phone", "555555");
 updateObjects.push(accountinfo);
 
 var update = sforceClient.Update(updateObjects);
 //window.parent.parent.location.href = '../setup/own/entityowneredit.jsp—retURL=../../home/home.jsp&id={!Account_ID}&p2=Bob Tester&save=1';
}
</script>
</head>

<body onload="updateaccountinfo()">
</body>
</html>

 

Message Edited by wkuehler on 05-30-2006 07:22 PM

Message Edited by wkuehler on 05-31-2006 05:57 AM

wkuehlerwkuehler
After doing some additional troubleshooting, it would appear that it does not like this line:

    var accountinfo = new Sforce.Dynabean("Account");

Any ideas why?

Message Edited by wkuehler on 05-31-2006 09:56 AM

wkuehlerwkuehler
Looks like I answered my own question.  Here is the code that fixed the problem.  Can anyone explain what the initPage function does exactly?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script src="http://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script language="JavaScript">

function initPage()
{
sforceClient.registerInitCallback(updateaccountinfo);
sforceClient.setLoginUrl("https://www.salesforce.com/services/Soap/u/7.0");
sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}", true);
}




function updateaccountinfo()
{
var updateObjects = new Array();

var accountinfo = new Sforce.Dynabean("Account");
alert("So far so good");

accountinfo.set("Id", "{!Account_ID}");
accountinfo.set("Phone", "555555");
updateObjects.push(accountinfo);

var update = sforceClient.Update(updateObjects);
//window.parent.parent.location.href = '../setup/own/entityowneredit.jsp—retURL=../../home/home.jsp&id={!Account_ID}&p2=Bob Tester&save=1';
}
</script>
</head>

<body onload="initPage()">
</body>
</html>

 

adamgadamg
That code block sets up the API connection within Javascript; looks like previously you were trying to access the API without doing setup first.
wkuehlerwkuehler
Makes sense.  Thanks