You need to sign in to do that
Don't have an account?
Unexpected element {urn:partner.soap.sforce.com}done during simple type deserialization
Hey guys,
In the case object, I store a number of lookup fields that they all have parent-child relationships. I'm trying to build a Custom Link which gets the parent lookup fields with OnClick JavaScript. I tend to use the Execute JavaScript behavior for my Custom Link. In my JavaScript code, I use a query function to retreive the parent object base on my criteria. The code is as follows:
{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} var newRecords = []; var C = new sforce.SObject("Case"); //Parent-Child Object Relationship is as follow: Terminal>>Part var PartParentTerminal = sforce.connection.query("SELECT Terminal__c FROM Part__c WHERE Part__c.Id= '{!Case.PartId__c}' "); //Updating parents via the PART association C.id ="{!Case.Id}"; C.Terminal__c = PartParentTerminal; newRecords.push(C); result = sforce.connection.update(newRecords); window.location.reload();
This custom link results in the following error code:
{faultcode:'soapenv:Client', faultstring:'Unexpected element {urn:partner.soap.sforce.com}done during simple type deserialization', }
I don't understand the error code and the reasons behind it.
I appreciate your thoughts about this issue.
Thank you,
Behzad
Do you thing adding the following line of code after my SELECT statement would get the QueryResults?
var TrmRecords = getParentTerminal.getArray("TrmRecords");
I've checked some of the Ajax Examples and in most of the examples they tend to use the getArray function right after they use the Select statement.
Can you explain how the Queryresult structure work?
All I'm trying to do is to update some lookup fields on my Case record, and all those lookup field have parent-child object relationship.
Is there a better way to achieve this?
Thank you,
Behzad
This works to get the Direct parent (Terminal__c field) of the Part:
{!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")}
var newRecords = [];
var C = new sforce.SObject("Case");
var Prt = "{!Case.PartId__c}";
//-------------PARTS-------------//
// Retrieve the parent Terminal from the Part lookup
var getPrtTrm = sforce.connection.query("Select p.Terminal__c From Part__c p where p.Id = '{!Case.PartId__c}' ")
var trmRecords = getPrtTrm.getArray("records");
for(i=0;i<trmRecords.length;i++){
thisPrtTrm = trmRecords[i];
C.id ="{!Case.Id}";
C.Terminal__c= thisPrtTrm.Terminal__c;
}
newRecords.push(C);
result = sforce.connection.update(newRecords);
window.location.reload();
The problem is, that now I have to get the Location__c Id field from the Terminal__c record that was found in getPrtTrm and place it on the Case field: Location__c
Then I need to get the Account__c field from that location and place it into the case as well...
Can someone show me an example of how I can go up another step?
I'm missing something.
Thanks,
JN