+ Start a Discussion

SControl question

Hi, Im a newbie to Salesforce, and I need to build a simple SControl rather quickly.
I am able to use merge fields to reference the data from the object (say, Opportunity) and display a form in the SControl. Is there a way I can post back data from SControl to the parent object - that is, I want to save certain changes made by the user in the SControl into the opportunity fields. Is this possible?
If so, how can I point the SControl form submit action to the Opportunity tab? The {!Scontrol_URL} takes me to the same page again. Also, I tried using some server-side (ASP) script in the SControl, and it does not seem to work. Can someone point me to a right direction? Thanks.
Have you tried the AJAX toolkit - have a look at this presentation for starters http://www.crmsuccess.com/browse/content_detail.jsp?id=006300000034wf6AAA
Thanks Andy. I started using the AJAX kit, and am able to use simple login calls and execute SELECT queries using Query method. But, how do I update data using SOQL - it does not seem to support UPDATE statements?? I need to update the data from my S-Control into the parent custom object record. Is there another way to do this without SOQL? Thanks.

It's not SOQL that performs updates or creates, you code it directly using a Dynabean - see example javascript below:  

 For create:          

var newOpp   = new Sforce.Dynabean("Opportunity");
var oppArray = new Array(1);
newOpp.set("CloseDate",   new Date());
newOpp.set("Name",        "something");
oppArray[0] = newOpp;
var cr = sforceClient.Create(oppArray);         opportunityID = cr[0].id;
For an update, use sforceClient.Update and make sure you set the Id eg. newOpp.set("Id", theID);  


 Hope that helps.


Andy, this is my code excerpt - its working well upto setting new value for AD_Client_manager__C in BQW record. After that, when I call sforceClient.Update, I get below error in updateResults, and value does not get updated. Can you help?

faultstring:java.lang.NumberFormatException: empty string

faultcode: soapenv: Server

Code Excerpt:

var BQWName = "{!Business_Qualification_Worksheet_Name}";

var qr = sforceClient.Query("Select Name,AD_Client_manager__c, Additional_Details__c, Date_and_Time__c, Id, Opportunity__c, PL_s_Affected__c, Potential_Profit_Margin__c, Potential_Project_Amount__c, Proposal_Submission_Date__c, Q1_answers__c, Q1_Notes__c, Q10_answers__c, Q10_Notes__c, Q2_answers__c, Q2_Notes__c, Q3_answers__c, Q3_Notes__c, Q4_answers__c, Q4_Notes__c, Q5_answers__c, Q5_Notes__c, Q6_answers__c, Q6_Notes__c, Q7_answers__c, Q7_Notes__c, Q8_answers__c, Q8_Notes__c, Q9_answers__c, Q9_Notes__c, Total_Score__c from Business_Qualification_Worksheet__c where Name = '" + BQWName + "'");

if (qr.getClassName() == "QueryResult")


if (qr.size == 1)


alert("Inside qr.size")

var BQW = qr.records[0]

var BQWName = BQW.get("Name");

alert("BQWName - " + BQWName);

alert("AD Manager - " + BQW.get("AD_Client_manager__C"));

BQW.set("AD_Client_manager__C", "ADMgr");

alert("AD Manager now - " + BQW.get("AD_Client_manager__C"));

var updateResults = sforceClient.Update(qr.records);




Hi Andy, the error occurs because one of the fields in the record is empty, which I should fix in another way. But, the update is working now. I am able to see the changes. Thanks.

Hi Andy,

I am making progress in my scontrol. Do you know if I can access the Profile of the user logged in - if he is a marketing manager etc from the sControl. Something close to GetUserInfoResult object in the API.



Ron HessRon Hess
i believe you can query the Profile table using SOQL passed thru the AJAX toolkit, it's just another table.

select ... from Profile where Id = 'the profile you want'

you may need to get the users profile id from the user table , and if you look around inside the AJAX toolkit src you can find a getUserInfo function which may return some info you need.