You need to sign in to do that
Don't have an account?
Update QueryResult MessageElement for QueryMore
How do I update the QueryResult in an SObject when I need to queryMore()?
I need to store the main SObject as my app queries and if the subSelect ! isDone then update the main SObject _any with the updated QueryResult.
essentially:
( (QueryResult)currentSObject.get_any()[loc].getObjectValue()).setRecords(qryR.getRecords());
I can't justoverwrite the ObjectValue as this throws a SOAPException
newME = existingME;
newME.setObjectValue(qryR);
newAny[loc] = newME;
Below seems to work to update the children, but then the values cannot be read back out.
The any element loses all the other settings.
currentSObject = getMainQueryRow(index);
MessageElement mel = sOB.get_any()[QRLocation];
if ( mel.getObjectValue().getClass().getSimpleName().equalsIgnoreCase( "QueryResult" ) ){
QueryResult qryR = (QueryResult) mel.getObjectValue();
if ( needMore ) {
//steps above are simplified to show how I got to the problem area
qryR = getQueryMoreQueryResult( qryR.getQueryLocator() );
MessageElement [] newAny = currentSObject.get_any();
MessageElement newME;
newME = new MessageElement("", mel.getName());
newME.setObjectValue( qryR );
Element e = newME.getAsDOM();
e.removeAttribute("xsi:type");
e.removeAttribute("xmlns:ns1");
e.removeAttribute("xmlns:xsd");
e.removeAttribute("xmlns:xsi");
newME = new MessageElement(e);
newAny[QRLocation] = newME;
} }
sorted.
You just have to throw away the Children before you set the new QueryResult.
qryR = getQueryMoreQueryResult( qryR.getQueryLocator() );
MessageElement [] newAny = currentSObject.get_any();
MessageElement newME = currentSObject.get_any()[loc];
newME.removeContents();
newME.setObjectValue(qryR);
newAny[loc] = newME;