- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 07:57 PM
Hi all,
Need your help in what could be wrong in the below code.
the expected result is when assignment group gets changed the assigned_to field value should be updated with a random person from the group however im not getting the result.
Appreciate your help.
SI:
Please consider only assignMembers function
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 11:59 PM
Thanks, as you can see, there is an error. Cannot read properties of null (reading length). Also before that error you can see null was logged, so member is null. Looking at your GlideAjax call again, you need to use sysparm_name when specifying the method to call, not just sysparm:
ga.addParam('sysparm_name', 'assignMembers'); // update this to be 'sysparm_name' instead of just 'sysparm'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 10:17 PM
Sorry, not sure what that is a screenshot of. If you can log to the console the value of member before your if-statement that will help. Then check your browser console for the log, not the System Logs table. I'm not sure what browser you're using, but typically you can right-click the page, inspect, and then check the Console tab after your code runs to see the log there
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 10:51 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 11:59 PM
Thanks, as you can see, there is an error. Cannot read properties of null (reading length). Also before that error you can see null was logged, so member is null. Looking at your GlideAjax call again, you need to use sysparm_name when specifying the method to call, not just sysparm:
ga.addParam('sysparm_name', 'assignMembers'); // update this to be 'sysparm_name' instead of just 'sysparm'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 12:13 AM
Thanks for the response, it worked but the result was not expected, attaching screenshot of the form after change which displays random count as 109 but there are only 7 members in grp.
Appreciate the help.
SI:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 12:17 AM
if the group has multiple members then how it will set in assigned _to field
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader