- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 04:23 AM
In an Incident form when assignment_group is changed the assigned_to field should become empty.
I need an On Change client script to execute this. Please help me with this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 07:53 AM - edited ‎05-23-2025 08:02 AM
Hi @yaddanki ,
we already have a client script OOB
check client scripts with below name: Empty assigned_to on group change
see if it is inactive and make it active
OOB script
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", "");
}
if not check below
use this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue != oldValue) {
g_form.clearValue('assigned_to');
}
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 07:53 AM - edited ‎05-23-2025 08:02 AM
Hi @yaddanki ,
we already have a client script OOB
check client scripts with below name: Empty assigned_to on group change
see if it is inactive and make it active
OOB script
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", "");
}
if not check below
use this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue != oldValue) {
g_form.clearValue('assigned_to');
}
}
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya