Multiple Value Mapping into one field
I am trying to map service output values into one field. The service returns multiple datasets in a grid. How would I combine the address values returned before it moves to the next set of data in the response?
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
I am trying to map service output values into one field. The service returns multiple datasets in a grid. How would I combine the address values returned before it moves to the next set of data in the response?
Hi Nathan,
You can map 2 data fields to one component and then merge them using such JS:prereturn element.text() + value;/pre
Thank you. How would I go about manipulating that string of data? For example, the fields I am mapping are as follows:
Street + City + State + Zipcode
Right now those values all run together when mapped to one component. I would like to add spaces and comma's to the string to format it properly. Could you explain how that would be done?
Nathan,
Something like this: preStreet + ", " + City + ", " + State + ", " + Zipcode/pre
I hate to be dumb, but could you explain that a little further please?
Nathan,
If the order of received data suits you, you can do this way.prevar count = (element.text().split(',').length - 1); // calculate a number of commas added to a label
var comma = (count != 3)? "," : ""; //if there are 3 commas added, then don't add in the end
return element.text() + value + comma; //add a new value to a text + comma /preThis is the simplest approach.
Kateryna,
I understand your response to this post. I would like to know how I could go one step farther and map 2 values from the response, but both values are from a pointer that is included in the response.
How would I do this?
Additionally, how would I map two values that come from an included pointer object inside an included pointer object inside the service response?
Hello Jack,
Please use JS of mapping from $ to field.
all item's data will be able in "value" variable.
E.g.:
return value.employee_ptr.username + " " + value.job_ptr.username;
Thank you Sergiy, that worked.
Last question. How would I do the same exact thing if I was trying to get from a storage variable (that is NOT an array) instead of a request?
You have to add mapping from the parent element to the field, then use the same JS as for array