How to use "useReturnValue"

Posted by meyrick on 31-Mar-2014 04:31

Hi there,

If I set useReturnValue="true", how would I access the value that is returned?

Regards,

Meyrick

All Replies

Posted by Fernando Souza on 31-Mar-2014 14:05

I am assuming you are talking about an 'invoke' operation. The response object should have a property called _retVal with the value returned, if any.

Posted by meyrick on 01-Apr-2014 02:49

How do you access the retVal? There seems to be no response object.

Posted by Fernando Souza on 01-Apr-2014 11:50

I think you will need to give me more context/details on what you are trying to execute (which operation type, from JavaScript? from a service? etc). Also, there is information in the "Mobile Applications" book on the use of _retVal.

Posted by Phillip Molly Malone on 01-Apr-2014 19:30

If you are using it from the Mobile AppBuilder and JSDO's, you can do it something like this in the event for an error:

------------

var errResp = JSON.parse(jqXHR.response);

console.log(errResp._retVal);

=======

This is taken from the "Run JavaScript" action of the "error' event of a JSDO read.

By the way, the JSON returned if its an error is something like this for an error returned by a rather default JSDO read operation with a return error in it:

--------------

{"_retVal":"This is the error","_errors":[{"_errorMsg":"ERROR condition: The Server application has returned an error. (7243) (7211)","_errorNum":0}]}

========

Hope this makes some sort of sense (I found it tricky to write up ;-) ).

Posted by meyrick on 02-Apr-2014 02:33

Hi Phillip,

How would I do that on success? I am needing to set a local storage variable to that return value. I used that same code you sent me except i changed your "console.log" to "alert", on success of the login service. It is displaying the errors correctly but on success no message comes up.

Posted by meyrick on 07-Apr-2014 04:42

Does anyone have a solution to my previous post?

Posted by Phillip Molly Malone on 09-Apr-2014 02:41

Hmmm..... that I haven't tried. Have you mapped the return value in the service definition in PDSOE? If I get a chance, I will have a look at it.

Posted by meyrick on 09-Apr-2014 02:54

Nope, not sure on how to map the return value because it doesn't display in the response.

Posted by maura on 09-Apr-2014 14:04

Can you tell us exactly what operation you are performing and trying to get _retVal. If it's an invoke operation, it should work for you. I just confirmed this.  The response object had a property called _retVal with the value returned.

If you're trying to do with a CRUD (Create, Read, Update, Delete) operation, it's not going to work. For these operations, we are not returning a response object.

Posted by Phillip Molly Malone on 09-Apr-2014 20:39

The mapping I am talking about is in the "Define Service Interface":


Let me know if this helps. (As I said, I haven't actually tested this on the mobile side)

Posted by maura on 10-Apr-2014 08:49

I tested an invoke operation on the mobile/client side and got back the _retVal in the response object for a successful transaction. Would like to know which operation  the original post-er was trying to get the _retVal for, as it's not supported for the CRUD operations.

This thread is closed