Get a nested json value of a single source field in transform map

Richard Tamparo
Mega Guru

Hello guys! I have another question. I tried searching for it already but can't find the answer so I'm posting it here. 

I will try to explain it in as detail as possible. Currently, I'm making a Transform Map based on JSON Data.  At this moment, I already know that writing a script is the Import side but I do not know what to write. What I need to do is to use a single source field for multiple target fields.

For example the value of source field "use_choicelist" are:

"data14333":[
  {
  "innerNo":"1",
  "value":"Use"
  },

  {
  "innerNo":"2",
  "value":"Dont Use"
  },

  {
  "innerNo":"3",
  "value":"Dont Use"
  },

  {
  "innerNo":"4",
  "value":"Use"
  },

  {
  "innerNo":"5",
  "value":"Dont Use"
  }
]

   

What I need to do is to use the data above to insert into different target fields.

                                       Transform Map

Import Table                                                                  Order Table

use_choicelist   <-----------------------------------------------> use_choice1   (value: Use)

use_choicelist   <-----------------------------------------------> use_choice2   (value: Dont Use)

use_choicelist   <-----------------------------------------------> use_choice3   (value: Dont Use)

use_choicelist   <-----------------------------------------------> use_choice4   (value: Use)

use_choicelist   <-----------------------------------------------> use_choice5   (value: Dont Use)

 

I hope you guys will help me. 

1 ACCEPTED SOLUTION

Richard Tamparo
Mega Guru

Thank you to 

shloke04 (congrats for becoming an MVP. Hoping I can be one in the future.)
Sourabh
 
I already fixed it thanks to you guys. 
 
var result;
var obj = JSON.parse(source.change_use_of_module);

for (var i = 0; i < obj.length; i++) {
if (obj[i].innerNo == "4") {
return result = obj[i].value;
}
}

View solution in original post

8 REPLIES 8

Nope you just need to define the Transform Script which is just beside the Field Map section. see image below:

find_real_file.png

Now select On After and use the script above as shown below:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

thank you for the very detailed reply. I will try it.

Richard Tamparo
Mega Guru

Thank you to 

shloke04 (congrats for becoming an MVP. Hoping I can be one in the future.)
Sourabh
 
I already fixed it thanks to you guys. 
 
var result;
var obj = JSON.parse(source.change_use_of_module);

for (var i = 0; i < obj.length; i++) {
if (obj[i].innerNo == "4") {
return result = obj[i].value;
}
}

Hi @Richard Tamparong 

Glad to help you here. Just confirming, if my solution helped you please mark my answer as correct and close this thread for others.

Thanks for wishing on the MVP status 🙂

Regards,

Shloke

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke