Page 1 of 2

custom js logic on service response

Posted: Sun Jan 05, 2014 6:07 pm
by Ilya

what is the api for service response? e.g. i want with moment js display date in particular format. i add custom js code to response - "moment().format('dddd');" but it doesn't work


custom js logic on service response

Posted: Sun Jan 05, 2014 6:12 pm
by maxkatz

Where exactly did you add the JavaScript?


custom js logic on service response

Posted: Sun Jan 05, 2014 6:16 pm
by Ilya

page - data - service - response - component (text field) (add js)


custom js logic on service response

Posted: Sun Jan 05, 2014 6:20 pm
by maxkatz

Test to make sure the script you are using works outside of mapping.. just by running it. Use the same data type/format that you get from the service.


custom js logic on service response

Posted: Sun Jan 05, 2014 10:32 pm
by Ilya

Hi Max. It works fine. You can check this here: http://appery.io/app/mobile-frame?src...
Please click on 'Заполнить время из перем..."


custom js logic on service response

Posted: Sun Jan 05, 2014 11:27 pm
by maxkatz

It works standalone and in mapping or only in standalone example?


custom js logic on service response

Posted: Mon Jan 06, 2014 8:15 am
by Ilya

Max, only in standalone mode. In mapping it doesn't work


custom js logic on service response

Posted: Mon Jan 06, 2014 2:04 pm
by Kateryna Grynko

Hi Ilya,

For mapping you should use the following JS: prereturn moment(value).format("dddd, MMMM Do YYYY, h:mm:ss a");/pre
Then a processed value will be returned to a mapped element.


custom js logic on service response

Posted: Tue Jan 07, 2014 10:35 am
by Ilya

Katya, thank you.
This worked for me.
Could you please explain the logic of the JS you provided.
E.g. the service provided response, then to whom it is 'return'ed? To the page? And then what is 'value'? It's value of response of service? Why is it called 'value'?


custom js logic on service response

Posted: Tue Jan 07, 2014 3:59 pm
by maxkatz

What code did you have before?

This explains what is 'value': http://docs.appery.io/documentation/r...