- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 02:10 PM
Hi All,
In the list view, i want to clear the Assigned to field if the Assignment group changes. Can anyone please correct my below code :
onCellEdit :
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 02:35 PM - edited 07-08-2024 02:43 PM
Hi @GP001
g_form is not available in list view scripts. It is only available in form view scripts.
and can you try the below script :
1 way of doing it.
function onCellEdit(sysIDs, table, oldValue, newValue, callback) {
var saveAndClose = true;
if (newValue != oldValue) {
saveAndClose = true;
var gr = new GlideRecord('incident');
if (gr.get(sysIDs)) {
gr.setValue('assigned_to', '');
gr.update();
}
} else {
saveAndClose = false;
}
callback(saveAndClose);
}
Here, Glide Record is not a good practice to use in client script. please enhance this by creating a script include or use business rules
and another way business rules(highly recommend)
you need to use before update business rule;
when condition : assignment group changes
action : assigned to Empty
then save
It will work and is working as expected in my PDI.
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 02:35 PM - edited 07-08-2024 02:43 PM
Hi @GP001
g_form is not available in list view scripts. It is only available in form view scripts.
and can you try the below script :
1 way of doing it.
function onCellEdit(sysIDs, table, oldValue, newValue, callback) {
var saveAndClose = true;
if (newValue != oldValue) {
saveAndClose = true;
var gr = new GlideRecord('incident');
if (gr.get(sysIDs)) {
gr.setValue('assigned_to', '');
gr.update();
}
} else {
saveAndClose = false;
}
callback(saveAndClose);
}
Here, Glide Record is not a good practice to use in client script. please enhance this by creating a script include or use business rules
and another way business rules(highly recommend)
you need to use before update business rule;
when condition : assignment group changes
action : assigned to Empty
then save
It will work and is working as expected in my PDI.
Thanks and Regards
Sai Venkatesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 09:34 PM
Hi @SAI VENKATESH,
Oh yes, it slipped my mind that we can't use g_form in list view. Thanks a lot for the suggestion. Your code works perfectly; i just needed to change ' if(newValue) '.
I much appreciate your help.