- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 02:39 AM
Hi!
I would like to make sure that if user changes >>assignment group<< to a different one, the >>Assigned to<< field is cleared out. Like this we are sure that only ppl from the assignment group can be assigned to the task.
Shall I use business rule to solve this?
thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 03:33 AM - edited 04-19-2024 03:35 AM
Hi @dev_K ,
I checked there is one OOB client script working on assignment group works on ONLOAD Firstly you can check your instance if this client script present or not, if not you can add that name "Empty assigned_to on group change"
You can create one client script and add below code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading)
return;
// Need to get the form value, in case it changes but then changes back to value in database (oldValue is always DB value)
if (oldValue != newValue)
g_scratchpad.formValue = newValue;
if (newValue === '' || newValue == null || oldValue != newValue || newValue != g_scratchpad.formValue) {
if(newValue && g_form.getValue("assigned_to")){
var groupLookupGr = new GlideRecord('sys_user_grmember');
groupLookupGr.addQuery('group.sys_id', newValue);
groupLookupGr.addQuery('user', g_form.getValue("assigned_to"));
groupLookupGr.setLimit(1);
groupLookupGr.query(groupLookupCallback);
} else {
g_form.setValue("assigned_to", "");
}
}
}
function groupLookupCallback(groupLookupGr){
if (!groupLookupGr.hasNext())
g_form.setValue("assigned_to", "");
}
Please refer below image
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 03:13 AM
Hi @dev_K
If you make the assigned_to field dependen of assignment group, if you change the group and the assigned-to is not in that groups it is automatically cleared. No need of scripts, BR, and so on.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 03:15 AM
how I can make assigned_to field dependent on the assignment_group?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 03:19 AM
Go to configure dictionary of Assigned to and check
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2024 03:33 AM - edited 04-19-2024 03:35 AM
Hi @dev_K ,
I checked there is one OOB client script working on assignment group works on ONLOAD Firstly you can check your instance if this client script present or not, if not you can add that name "Empty assigned_to on group change"
You can create one client script and add below code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading)
return;
// Need to get the form value, in case it changes but then changes back to value in database (oldValue is always DB value)
if (oldValue != newValue)
g_scratchpad.formValue = newValue;
if (newValue === '' || newValue == null || oldValue != newValue || newValue != g_scratchpad.formValue) {
if(newValue && g_form.getValue("assigned_to")){
var groupLookupGr = new GlideRecord('sys_user_grmember');
groupLookupGr.addQuery('group.sys_id', newValue);
groupLookupGr.addQuery('user', g_form.getValue("assigned_to"));
groupLookupGr.setLimit(1);
groupLookupGr.query(groupLookupCallback);
} else {
g_form.setValue("assigned_to", "");
}
}
}
function groupLookupCallback(groupLookupGr){
if (!groupLookupGr.hasNext())
g_form.setValue("assigned_to", "");
}
Please refer below image
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak