Nathan Friend
Posts: 0
Joined: Fri Jan 31, 2014 3:56 pm

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?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Multiple Value Mapping into one field

Hi Nathan,

You can map 2 data fields to one component and then merge them using such JS:prereturn element.text() + value;/pre

Nathan Friend
Posts: 0
Joined: Fri Jan 31, 2014 3:56 pm

Multiple Value Mapping into one field

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?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Multiple Value Mapping into one field

Nathan,

Something like this: preStreet + ", " + City + ", " + State + ", " + Zipcode/pre

Nathan Friend
Posts: 0
Joined: Fri Jan 31, 2014 3:56 pm

Multiple Value Mapping into one field

I hate to be dumb, but could you explain that a little further please?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Multiple Value Mapping into one field

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.

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

Multiple Value Mapping into one field

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.

Image

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?

Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Multiple Value Mapping into one field

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;

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

Multiple Value Mapping into one field

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?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Multiple Value Mapping into one field

You have to add mapping from the parent element to the field, then use the same JS as for array

Return to “Issues”