Page 1 of 1

How to merge two fields from Rest service response

Posted: Mon Aug 27, 2012 1:52 pm
by Rutger van Dijk

While creating data mapping between response of Rest service call and elements on the page, I would like to know if it is possible to do the following:

Can I easily map fields [Name] and [Percentage] to a text label in the following format:

"[Name] ([Percentage])"

Image


How to merge two fields from Rest service response

Posted: Mon Aug 27, 2012 6:49 pm
by maxkatz

If you map Name and Percentage to the same page components, you will get both of them passed, just not together. It will be in the same execution, but first Percentage and then Name will be passed:

Percentage
Name

One option is to save Name into local storage.

Another option is to mapped them to different page components

Percentage -- percentageComponent
Name -- nameComponent

For nameComponent, you could add this JavaScript to get the value for percentage:
code
var p = Tiggzi('percentegeComponentName').text();
/code

Now you have both values.


How to merge two fields from Rest service response

Posted: Fri Nov 29, 2013 9:52 pm
by bahar.wadia

I have the same question.

I have FirstName and LastName as two fields. I want the two Fields displayed in only one Label "FirstName LastName". Having two separate fields make the GUI look very 1980s.

Also, I need to be able to do this on a query that return multiple records.

Any tricks?


How to merge two fields from Rest service response

Posted: Fri Nov 29, 2013 10:27 pm
by Igor

Hello,

You can map FirstName and LastName to the one page component.
http://docs.appery.io/documentation/u...


How to merge two fields from Rest service response

Posted: Sat Nov 30, 2013 12:04 am
by bahar.wadia

Can you point me where this is on the page you reference. I don't see anything similar to my question. Also, I would want FirstName before LastName. How would you do that ?


How to merge two fields from Rest service response

Posted: Sat Nov 30, 2013 12:52 am
by Igor

There is no exact example like you need in the above link. Screen shot should help:

Image


How to merge two fields from Rest service response

Posted: Sat Nov 30, 2013 10:17 pm
by bahar.wadia

This is helpful.

How would I know which variable get updated first ?

Does the local variable always get assigned first ? If not, then the results will be random.

Can you please confirm.

Thanks


How to merge two fields from Rest service response

Posted: Sun Dec 01, 2013 6:10 am
by Illya Stepanov

Hi bahar.wadia, sorry for delay. I'm not sure I understand your questions - can you explain in more details what exactly is confusing you?


How to merge two fields from Rest service response

Posted: Sun Dec 01, 2013 7:18 am
by Igor

First localStorage variable will be updated.
In this situation you need to assigned localStorage variable first. Also you can map First and Second name to localstorage variables and merged localstorage values to some component.