- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 07:45 AM - edited 04-21-2023 07:47 AM
Can anyone please tell me why I'm getting "Error: o,Detail: Unexpected token: o" this error for below code? here privilaged_user is a Array.Object
privilaged_user =
[ {
"privileged_user_account_name" : "s5gb78e7rgt5a95070e322fatg9619kl",
"privileged_user_account_type_multi" : "RegularUser",
"privileged_user_email_address" : "aksingh@gmail.com"
} ]
and approver is a reference field
(function execute(inputs, outputs) {
var mrvs = inputs.privilaged_user;
mrvs = JSON.parse();
var users = mrvs[0].privileged_user_account_name;
outputs.approver = users.toString;
})(inputs, outputs);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 08:40 AM
Hi @mickydash2001 ,
I trust you are doing great.
After reviewing the code, it seems like the issue is with the line that contains "mrvs = JSON.parse();". This line is attempting to parse the "mrvs" variable as JSON, but it is missing the argument that specifies the JSON string to be parsed.
To fix this issue, you should pass the "mrvs" variable as an argument to the JSON.parse() function, like this:
mrvs = JSON.parse(mrvs);
Additionally, there are a few other issues with the code that need to be addressed. Here is the updated code with these fixes:
(function execute(inputs, outputs) {
var privileged_users = inputs.privilaged_user;
var users = privileged_users[0].privileged_user_account_name;
outputs.approver = users.toString();
})(inputs, outputs);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 07:52 AM - edited 04-21-2023 07:53 AM
In my experience, an array with JSON inside of it does not parse the JSON object when calling the parse on the array. Please try this and see if you get the same error:
(function execute(inputs, outputs) {
var mrvs = inputs.privilaged_user;
mrvs = JSON.parse(mrvs);
var user_object = JSON.parse(mrvs[0]);
var users = user_object.privileged_user_account_name;
outputs.approver = users.toString;
})(inputs, outputs);
Edited: I noticed you weren't parsing anything, so I edited the mrvs line to run the parse on the mrvs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 09:19 AM
Hi @Joshua_Quinn ,
Thanks for the reply.
I tried this solution still facing the same error. Is there anything else I can modify?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 08:40 AM
Hi @mickydash2001 ,
I trust you are doing great.
After reviewing the code, it seems like the issue is with the line that contains "mrvs = JSON.parse();". This line is attempting to parse the "mrvs" variable as JSON, but it is missing the argument that specifies the JSON string to be parsed.
To fix this issue, you should pass the "mrvs" variable as an argument to the JSON.parse() function, like this:
mrvs = JSON.parse(mrvs);
Additionally, there are a few other issues with the code that need to be addressed. Here is the updated code with these fixes:
(function execute(inputs, outputs) {
var privileged_users = inputs.privilaged_user;
var users = privileged_users[0].privileged_user_account_name;
outputs.approver = users.toString();
})(inputs, outputs);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 09:25 AM
@Amit Gujarathi Thanks for the solution. The issue got resolved.