how to pass values to json object

Priti18
Tera Expert

how can I pass the incident category value dynamically in key value format

 

var inccategory = current.category.getDisplayValue();

 var result = "{'category':inccategory} // this gives me error but if I print logs then I am able to see correct value

1 ACCEPTED SOLUTION

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

Remove the quotes around the curly braces:

var result = {"category":inccategory};

View solution in original post

10 REPLIES 10

then how to pass value of category in flow 

Please share where are you writing this code. screenshot please.


Thanks and Regards,

Saurabh Gupta

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

Flow designer is different. It really depends on where you are trying to access your incident record (flow, subflow, action, is it a trigger or a result of look-up, etc.), but basically you can get to it starting from the fd_data object.

For instance, if your incident is the trigger of the flow, it would look like this:

fd_data.trigger.current.category.getDisplayValue();

Priti18
Tera Expert

under actions I am trying to send value to 3rd party where am passing the value of category (label value) to key

var inccategory = fd_data.trigger.current.category.getDisplayValue();

gs.info('print category ' + inccategory); // gives me correct value

 var result = '{"category":inccategory}'; // this part doesn't take above value instead it shows inccategory

return result;

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

Remove the quotes around the curly braces:

var result = {"category":inccategory};