- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
01-25-2023 01:49 AM
Hello,
I'm creating Json lists introducing data in them. I'm using "addToList" automation. The data introduced example:
listData:
{"key1":{
"subkey1: ${dataInput1},
"subkey2: ${dataInput2},
"subkey3: ${dataInput3},
"subkey4: ${dataInput4}
}
Is there a way to transform the variables directly in the input listData with no need to create a set for each dataInput?
04-26-2023 01:47 PM
Hi @Josep
The simple answer to your question is yes, you can use transformer to write for loop to get each ${datainput} value but it's not quite simple. You will need to utilize DT (General) and to write JavaScript for loop code.
For the task, Get = ${dataInput} assuming this is a simple list with different items instead of a Json object.
For the Transformer, here is what you would enter:
.=>val.map(function(elem){
my_str="subkey";
tags=elem{'dataInput};
tagnames="";
for(i=0;i<tags.length;i++){
my_str=my_str+i=","
tagnames=tagnames+tags[i]+",";}
return {my_str.slice(0,-1):tagnames.slice(0,-1)}})
Obviously, I cannot guarantee that this DT will work for your incident since there are a few variables that I would need to know and this will require testing in your instance. I would suggest to play around with DT.
Good luck!
Yuki
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!