- 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 08:06 PM - edited 05-29-2024 08:07 PM
You should be setting the sys_id, not the name on the assigned_to reference field. You can use the third argument of the setValue() method to specify the display value to be the name, but the second argument should be the sys_id:
var randomMember = member[randomNum];
g_form.setValue('assigned_to', randomMember.sys_id, randomMember.name);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 08:44 PM
thanks for the response, updated the code as suggested but still no change in solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 09:01 PM - edited 05-29-2024 09:01 PM
In your updated code you've shared, you've commented out the line that created the randomNum variable. You still need that line for getting the random member from your array when creating the randomMember variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2024 09:05 PM
Hi
I uncommented that line, still no update.