- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 09:17 AM
Hi,
I have tried everything I can think of and nothing works so I really need help ("You are my only hope" lol).
So I have this workflow that is triggered from an Integration Queue Record and so it will have the payload itself (JSON) and the Integration Queue Number that is assigned to that record.
I am trying to modify my existing payload to add the IQ number to that JSON. The issue is that I can't seem to pass that variable into the JSON object - it either appears blank or literal variable name instead of variable value.
var myPayload = fd_data.trigger.current.u_payload; //this is the current payload
var myIQnumber = fd_data.trigger.current.u_number; //this is the integration queue number
var obj = JSON.parse(myPayload); //change back to object
obj.IQname = myIQnumber; //adding the IQ number to the JSON payload
var newPayload = JSON.stringify(obj); //convert object back to string
return newPayload;
here is the result:
If I try to escape the variable like I do in the workflow, for example:
obj.IQname = "+myIQnumber+"; //adding the IQ number to the JSON payload
That will literally result in JSON output looking like:
{...,"IQname":"+myIQnumber+"}
Help!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 11:25 AM
Finally got it to work today, switched my method a bit
var myPayload = fd_data.trigger.current.u_payload; //this is the current payload
var myIQnumber = fd_data.trigger.current.u_number; //this is the integration queue number
var obj = JSON.parse(myPayload); //change to object
var IQ = 'IQnumber'; //this is the key of the JSON's key value pair, it assumes that it already exists
obj[IQ] = ""+myIQnumber+""; //proper escape //sets the value (assuming that key exists, if not then do: obj.IQnumber)
var newPayload = JSON.stringify(obj); //convert object back to string
return newPayload;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 11:25 AM
Finally got it to work today, switched my method a bit
var myPayload = fd_data.trigger.current.u_payload; //this is the current payload
var myIQnumber = fd_data.trigger.current.u_number; //this is the integration queue number
var obj = JSON.parse(myPayload); //change to object
var IQ = 'IQnumber'; //this is the key of the JSON's key value pair, it assumes that it already exists
obj[IQ] = ""+myIQnumber+""; //proper escape //sets the value (assuming that key exists, if not then do: obj.IQnumber)
var newPayload = JSON.stringify(obj); //convert object back to string
return newPayload;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2021 11:45 AM
Hi,
You can put logs in your script to p rint value of your variable myIQnumber before adding to payload.
Also make small change and use
obj.IQname= myIQnumber.toString();
Thanks,
Anil Lande
Thanks
Anil Lande