You need to sign in to do that
Don't have an account?
Ajax Toolkit: sObject type 'sObject' is not supported
Hello,
In the following javascript, i'm trying to 1.) Query a case 2.) Update a field based on a page parameter. When I try to update the case, salesforce is kicking back an error:
failed to update case {errors:{message:'sObject type 'sObject' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.', statusCode:'INVALID_TYPE', }, id:null, success:'false', }
Here is the code:
function chooseRep(id){ var fieldName = '{!$CurrentPage.parameters.field}'; sforce.connection.sessionId = '{!$Api.Session_ID}'; var result = sforce.connection.query("SELECT id, Sales_Rep__c, NDS_Assigned__c FROM Case WHERE ID = \'{!$CurrentPage.parameters.id}\'"); if(fieldName == 'SalesRep'){ result.records.Sales_Rep__c = id; }else{ result.recoreds.NDS_Assigned__c = id; } var result2 = sforce.connection.update([result.records.Id]); if (result2[0].getBoolean("success")) { alert("case with id " + result2[0].id + " updated"); } else { alert("failed to update case " + result2[0]); } var previousCase = "{!$CurrentPage.parameters.id}"; window.location.href = "/" + previousCase; }
I'm thinking I need to cast the "result" variable to a case, but i'm not exactly sure how to do that via the Ajax Toolkit.
Thanks!
Mike - Lets see if this works:
All Answers
Mike - Lets see if this works:
Now i'm getting a different error via the web browsers console:
uncaught exception: arg 0 'sObjects' is an array. But passed in value is not an array
When I tested it, I confirmed I was getting a record returned from that specific query.
It's the var result2 = sforce.connection.update(caseObj); line.
I also tried: var result2 = sforce.connection.update(caseObj.Id);
But that rendered the same result.
Got it working: It needed to change the sforce.connection.update([caseObj]);