- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2022 04:04 AM
Hello All,
I have written the below code snippet in my Actions in Flow Designer.
var response = inputs.parameter;
var obj =JSON.parse(JSON.stringify(response));
outputs.employee = obj.EmployeeNumber;
if(outputs.employee)
{
outputs.iscontractor = 'no'
}
else
{
outputs.iscontractor = 'yes'
}
Action input type is String.
I am receiving an Error "Error:o.Detail:Unexpected token:o"
Any help on this is highly appreciated.
Thanks,
Arun Devendran
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2022 05:20 AM
Hello Ankur,
Thanks for replying.
I have made modifications;
var response = inputs.parameter;
var parser = new JSON();
var obj = parser.decode(response);
outputs.employee = obj.EmployeeNumber;
This is working fine now.
Thanks,
Arun Devendran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2022 04:16 AM
Hi,
which line is giving error?
if your input is string then why to stringify again?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2022 05:20 AM
Hello Ankur,
Thanks for replying.
I have made modifications;
var response = inputs.parameter;
var parser = new JSON();
var obj = parser.decode(response);
outputs.employee = obj.EmployeeNumber;
This is working fine now.
Thanks,
Arun Devendran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2022 07:31 AM
this is what I mentioned exactly. no need to stringify
Glad to know.
If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2022 12:39 AM
Hello Ankur,
Used JSON.parse() before using stringify, but it didnt work.
This one parser.decode helped solving the issue.
Best Regards,
Arun Devendran