- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 06:25 AM
Hi Everyone,
I want to modify the value of "Assignment group" task field of a catalog item, depending on a variable value of the catalog.
For example, if the variable = a, "Assignment group" of the task field is the default value "Group A".
if the variable = b, then "Assignment group" value should be "Group B".
However, no matter what I tried (with workflow script, Business Rule, client script), with variable =b the value remains the default one "Group A".
In Workflow, I used following code under "Catalog task" activity:
task.assignment_group = "Group B";
This actually worked with the description field, but not with assignment_group...
In BR, I used following code:
current.assignment_group ="Group B";
This didn't worked at all even with description field. I also tried with "Actions tab"
With client script, the value is replaced with "Group B" on the form, but when I save and reload the form, default value is displayed again.
For information, I can't remove the "Assignement group" default value because it is mandatory at the task creation.
If someone has an idea how to manage this, I would be very thankfull !
Kr,
Sylvain
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 09:48 AM
This all looks correct. Can you verify for me that the sys_id in the script is the sys_id of the group (take that sys_id, go to the sys_user_group table and add a filter for sys_id is <insert_sys_id> and make sure that the group you expect comes back). Also, my apologies, you are correct; you don't need the .update() within the workflow node. My mistake.
If that is working, then there has to be something (an assignment rule, business rule, etc) that is overwriting your value. Is the u_catalog_item value that you are setting in that script working? You can also check the system logs to see if there is an error when this node is being ran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 08:08 AM
In both of these scripts, did you use task.update() for the first or current.update() for the second? I just want to make sure we have all of our bases covered.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 08:34 AM
I did not, but this is used with Glide Record API isn't it ?
Anyway I just tried and result is the same 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 08:37 AM
GlideRecord is an object in ServiceNow, so in order to update the record that the GlideRecord is referencing, you need to call the update function, especially for referencing another table like the task object in your first example. I'm sorry that it didn't work this time. Can you look at the audit history on the task to see if the assignment group is changing back to the default and if the desired assignment group is ever being set during/after creation?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 08:56 AM
I looked into sys_audit table, is this the right way ?
I filtered with assignment_group and my login, sorted by dated, and only 2 rows are displayed in the table with today date, although I made way more tests today, so please let me know if I am doing this wrong.
On last raw, old value is empty, new value is default value.
On second raw, old value is default, new value is desired sys_id of the group, however I think it corresponds to the update I did manually .
(Side note about GlideRecord, I am not using it, I directly input the one line of code I shared:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 09:48 AM
This all looks correct. Can you verify for me that the sys_id in the script is the sys_id of the group (take that sys_id, go to the sys_user_group table and add a filter for sys_id is <insert_sys_id> and make sure that the group you expect comes back). Also, my apologies, you are correct; you don't need the .update() within the workflow node. My mistake.
If that is working, then there has to be something (an assignment rule, business rule, etc) that is overwriting your value. Is the u_catalog_item value that you are setting in that script working? You can also check the system logs to see if there is an error when this node is being ran.