Getting error in the script task. I'm trying to pass the below jsonPV in PM.I want to store the id values in DB as separate row
Discussion posts and replies are publicly visible
Sure! The issue is happening because you're iterating only at the top level. To save each employeeID along with its corresponding emailAddress, you’ll need to flatten the structure using nested a!forEach().This code might help you generate one row per id with its corresponding email address.
employeeID
emailAddress
a!forEach()
id
I will enter some emailaddresses on UI .After integration is success then it has save Email & ID related to that in db in each row.Example : {id: "abcienbfe" ,email:"tet@test.vom" ; {id:"124n2iw",email:"test@test.com"}}In DB my value should be stored as requestid(foreignkey ,employeeID,emailAddress)1 abcdei test@test.vom2 124n2i1 test@test.com
I need to create this rule in Processmode? can you please explain in detail
Yes, this can be handled in the process model. The cleaner approach is to use an expression rule that takes the JSON and requestId, transforms the data, and returns the list of records. You can call it in a Script Task post-integration. That said, if it’s a one-off, you can also write the expression logic directly in the Script Task ~ both work, just depends on how modular you want it. After that, simply pass the result to a Write to Data Store Entity or Write to Records node to save it to the DB.
Then a single Table is enough and write the whole data at once using script task and write records
I'm trying to pass your expression rule in the script task as below .I'm getting below error
The error indicates that a!fromJson() is receiving an invalid input. If pv!jsonPv is already a map (not a JSON string), you don’t need to parse it again, just use it directly in your loop. If it is a string, make sure it’s valid JSON (you can check it on any json validators available online).
a!fromJson()
pv!jsonPv