
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 10:04 PM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2022 03:32 AM
Thank you to
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 10:16 PM
Hi,
In this case you just simply need to create Field Map Script as below.
You can see below in the field map open it and configure the script as written below.
Note : Select Use Source Script check box as true.
var result;
var choiceJSON = JSON.parse(source.use_choicelist); //Converting use_choicelist as JSON object.
//Check for each innerNo value
for(var filed in choiceJSON){
//for table use_choice1
if(choiceJSON.filed.innerNo == '1'){
result = choiceJSON.filed.value;
target.FIELD_NAME = result; //Use the target table field
}
//Similarly you can check for all other values and do the modification as per your need.
}
Mark this as Helpful, if Applicable.
Regards,
Sourabh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 04:36 AM
Thank you so much for the reply and Im sorry for the late reply as I was trying to fix how it can work. it says undefined.
Cannot read property "value" from undefined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2022 10:55 PM
Hi,
Write a On After Transform Script and use the script below to map this JSON object to different target field of your.
Script to be used in On After Transform script:
var str = source.FIeldNAME;
var parsed = JSON.parse(str);
var getParsedLength = parsed.length;
for(var i=0;i<getParsedLength;i++){
if(getParsedLength[i].innerNo == '1'){
target.fieldName = getParsedLength[i].value;
}else if(getParsedLength[i].innerNo == '2'){
target.fieldName = getParsedLength[i].value;
}
target.update();
}
This way you can check for each Inner Number and map it to different Target field with the values you need.
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2022 04:37 AM
Thank you so much for the reply and Im sorry for the late reply.
If Im gonna add this, do I have to add a script field map?