Get l&M row number to use as index. | XM Community
Skip to main content
I have a L&M block with 4 fields and 5 rows. These represent 5 products with 4 different attributes. They are defined in the customer’s inventory (aka embedded data fields). These attributes are named UA1, Make1, Manuf1, Cost1, Type1 for example. The second product is UA2, Make2, Manuf2, Cost2, Type2, etc....I have piped embedded data values into the cells to pre-populate the fields in the questions in the block. There are 5 questions of mixed types (Form, text, multi-select, etc). I then have a question prior to the block where I ask - Which products do you want to review/update? The customer can select from UA1-UA5 using a multi select box. I use the selected choices to loop and merge.



In the L&M block, I set the default values to ${lm://Field/1}, ${lm://Field/2}... then the customer can change the value in the text box, multi-select, etc.. What I now want to do is take that new entry and put it back in the embedded data field that coincides with that entry.



UA1 has a value of GOAT, Make1=Ewe, Manuf1=farmer, Cost1=100, type1=big

UA2 has a value of Pig, Make2=SOW, Manuf2 = sty, Cost2=50, type2=pink

UA3 = Dog, Make2=Bitch, Manuf3=Kennel, Cost3=10, type3=fuzzy





Ex. The customer selected GOAT and Dog on the question prior to the loop. So what shows up in the first loop of the form question at the top of the L&M block is:

Name. GOAT

Make Ewe

Manufacturer Farmer



The customer changes the Make = Hen. I now want to store Hen, into the embedded data field Make1.



On the second loop the question contains

Name. Dog

Make. Bitch

Manufacturer. Kennel

And the customer changes Kennel to Shelter. I want to save Shelter into the ED field Manuf3.



I get the updated values but I can’t figure out how to append the 1 or 3 to the “Manuf”, “Make”, “UA” ED field names to store the right value.
Add a field 5th field to your Loop & Merge that contains the index. Then to save the ED:



Qualtrics.SurveyEngine.setEmbeddedData("Manuf"+"${lm://Field/5}",newValue);
Thanks! That sounds so easy.I'll give it a try.

Leave a Reply