function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
radanradan 

structure of values returned by apex.execute() in JavaScript

I am invoking Apex code in this manner:
    
   var result = sforce.apex.execute(...);
 
The Apex code  is returning a value of type Id.  

If I grab this result and assign it to a field value that requires an Id, and invoke the connection.insert or update methods,

I get an error "duplicate values specified for <field>"  and an exception is thrown in connection.js

The work around I am using is to return a string value instead and assign it to another string

Like:

       var res = '';  result = sforce.apex.execute(..); res += result

 

Now if i use the res as the value for Id fieldinsert/update etcsucceed.

[If I directly use result  which is of String type now, I get the same duplicate values specified error. When I dump the value of the variables to console, they look ok..]

 

Can someone enlighten me on the correct way to 

unpack result values returned by sforce.apex.execute() call?

The documentation example provided uses the return values with out any subsequent massaging.

 
      Thanks