How to use "useReturnValue" - Forum - Mobile - Progress Community

How to use "useReturnValue"


How to use "useReturnValue"

  • Hi there,

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



  • 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.

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

  • 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.

  • 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);



    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 ;-) ).

  • 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.

  • Does anyone have a solution to my previous post?

  • 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.

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

  • 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.

  • 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)

  • 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.