You need to sign in to do that
Don't have an account?

Ajax Beta1 S-Control Help
Can I not do a get and set with the same retrieve object? Does not update the Status.
//Get Salesforce connection based on users current session id
sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");
window.setTimeout(";", 1000);
sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");
window.setTimeout(";", 1000);
var orderIds = new Array();
orderIds[0] = "{!Order_ID}";
var orderRetrieve = sforceClient.Retrieve("AccountId, Status", "Order", orderIds);
if(orderRetrieve[0] != null) {
var orderAccountId = orderRetrieve[0].get("AccountId");
alert("AccountId - " + orderAccountId);
alert("Status - " + orderRetrieve[0].get("Status"));
orderRetrieve[0].set("Status", "5 - Completed");
alert("Status - " + orderRetrieve[0].get("Status"));
sforceClient.Update(orderRetrieve);
orderIds[0] = "{!Order_ID}";
var orderRetrieve = sforceClient.Retrieve("AccountId, Status", "Order", orderIds);
if(orderRetrieve[0] != null) {
var orderAccountId = orderRetrieve[0].get("AccountId");
alert("AccountId - " + orderAccountId);
alert("Status - " + orderRetrieve[0].get("Status"));
orderRetrieve[0].set("Status", "5 - Completed");
alert("Status - " + orderRetrieve[0].get("Status"));
sforceClient.Update(orderRetrieve);
}
Without looking too carefully, in your code, orderRetrieve isn't a single Dynabean which can be used in an update. It's an array.
Steve Bower
Code:
Still getting an issue with set/update of the dynaBean the upateResults displays:
id: success: false errors fields autoNumber: false byteLength: 0 calculated: false createable: false custom: false defaultedOnCreate: false digits: 0 filterable: false label: length: 0 name: nameField: false nillable: false picklistValues: precision: 0 referenceTo: restrictedPicklist: false scale: 0 soapType: type: updateable: false message: invalid cross reference id statusCode: INVALID_CROSS_REFERENCE_KEY
Thanks for any suggestions,
-Benj
Code:
Ahhh. Must have object Id to know what to Update (see code change above). Now I have a new issue. One of the return values is not updatable (AccountId). Is there a good practice for doing this in one call (i.e. maybe removing AccountId from message) instead of making two calls one for Status (updatable) and the other for AccountId (not updatable)?
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);
alert(updateResults);
}
}