I am trying to use inject js activity to automate data entry on a web form. I have the js script ready and is working fine. But I am planning to create it as a reusable component so that I can use it somewhere else in the same process.
I would like to pass the “field id” and “value” as the parameters for inject js. For that I have created an array of string and populated it with “values” . And then converted it to json string. Later this json string is passed into the script. This works perfectly.
But how can I pass the field id also in this manner in such a way that the script becomes capable to handle dynamic field ids and values.
How can I make a single json string for field id and value?
The field ids and values are both string.
Example input:
Field id1: fname Value1: John
Field id2: lname Value2: Smith
Field id3: zip Value3: 70890
Thanks, but in my case the number of fields and their values are dynamic. In the above example you shared you assumed there are only 3 fields ids and 3 values. Its correct.
But what I am looking for is an approach where the bot should be able to create a dictionary based on the array of string of any size I pass as argument to that workflow.
How can we handle this so that based on the argument I pass the corresponding dictionary is created which I can serialize and pass it as parameter for inject js.
Note= the array size will be always equal for both arguments. For eg: if there are 5 field ids there will be 5 values.
I hope I am clear, else I am happy to explain in detail.
But how can I create a dictionary of dynamic size? You have created one with size 3, hence you were able to place the input strings accordingly.
What if the size keeps on changing and want to create based on the array size of input provided. If the array size of field id and value is 5 , then create dictionary of size 5 with those values respectively.
Similarly for any array size. This is something I am finding difficult to crack.
I tried this expression and went through the essentials also. I am not getting the “.todictionary” namespace at my end. Do I have to import any namespace?