Reponse area one item error

This forum contains topics that were moved from Get Satisfaction
Ihor Didevych
Posts: 0
Joined: Wed Nov 19, 2014 7:55 pm

Reponse area one item error

Post by Ihor Didevych »

Hi Hnto,

We are sorry that you had trouble with this issue. We will try to find workaround.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Reponse area one item error

Post by Evgene Karachevtsev »

Hello Hnto,

As Yurii mentioned in the link below
1) This is one of approaches:
prevar onSuccess = function(data){
alert("serviceresponse");
//Using response.
};
serviceName.execute({success: onSuccess});/pre
With this code you get the data from response, but you need to make your own mapping.

2) The other way is to parse xml with use of jQuery
http://api.jquery.com/jquery.parsexml/

3) The last and more efficient way is to:
a) get xml
b) add library https://code.google.com/p/x2js/ to your app
c) launch javascript with used of imported library and parse all to json
d) create Generic REST Service that will return generated json
After this step you will get your normal mapping

Hein
Posts: 0
Joined: Sun Aug 02, 2015 2:53 pm

Reponse area one item error

Post by Hein »

Found this on the docs, however it'd be better if these methods can be written in more details. I have to idea when you mean 'launch javascript', and from where? etc...

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Reponse area one item error

Post by Yurii Orishchuk »

Hi Hein,

Here is workaround for this problem:

  1. Add to your service datasource "success" "javascript" event handler before mapping.
    Details: http://prntscr.com/615h4s/direct

  2. Populate this javascript with following JS code:
    Details: http://prntscr.com/615ik7/direct

    pre

    //Where "note.tag" is path to your response array. You should replace this part with yours.
    data.note.tag = _.isArray(data.note.tag) ? data.note.tag : [data.note.tag];

    /pre

    See example of how to get "note.tag" in the code: http://prntscr.com/615j9q/direct
    So you should open your success mapping and find "path" to your array and replace with this part "note.tag"

    Regards.

Post Reply