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
The error occurs because a!fromJson() expects a Text input with valid JSON, but pv!jsonPv is already a Map (parsed structure). You don’t need to use a!fromJson() in this case. or you could change the type of your process variable to text .Hope this helps! Let me know if you’d like more assistance.
a!fromJson()
pv!jsonPv
Hi Megha Ramnani I want to save the ID values in employeeIDs as a row in db for each emailaddress but now it is taking only value of first emailaddress. can you please help
You need to iterate the IDs from Result PV, take an output, construct the record and save it Use PV as multiple, I can see the output_Requests is not multiple.You cannot add multiple IDs to a single employeeIDs column, if you are doing that.
Shall I create a separate DB for mail & employeeIds and then create record for it .After that , in process model i need to call this record to store the ID values..?
can you briefly explain what you want to achieve?Just a scenario is pretty enough!
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.
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).