- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 05:43 AM
Hi i make to assigned to field empty whenever assignment group changes. i tried onchange scritp, but its still not working.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 05:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:07 AM
Hello @Deepanshi1
You can create before BR (apply on both form and list view) with insert/update with conditions are:
'Assigned to' is not empty AND 'Assignment group' changes AND 'Assignment group' is not empty
=> In the Actions tab, set 'Assigned to' to empty.
Please mark my answer helpful if I have answered you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:21 AM
Hi @Deepanshi1
use below script in onchange client script on field assignment group
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if(newValue==''){
g_form.clearValue('assigned_to');
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:21 AM
Hi @Deepanshi1
I've written a simple On-change client script & it seems to be working as per your requirement.
Please find the attached screenshot for your reference & below is the code which can be used to clear Assigned to when Assignment group changes.
Please mark it as Accepted if it worked for you or feel free to reply so that I can check it furthermore.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(oldValue!=newValue)
{
g_form.clearValue('assigned_to');
}
//Type appropriate comment here, and begin script below
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:24 AM
Hi @Deepanshi1 ,
Have you looked into the OOTB client script for incident table "Empty assigned_to on group change" which contains the onchange client 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", "");
}
This client scripts empties the assigned to based on the assignment group as you're requesting.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 05:44 AM
Please share code snippet.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:07 AM
Hello @Deepanshi1
You can create before BR (apply on both form and list view) with insert/update with conditions are:
'Assigned to' is not empty AND 'Assignment group' changes AND 'Assignment group' is not empty
=> In the Actions tab, set 'Assigned to' to empty.
Please mark my answer helpful if I have answered you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:21 AM
Hi @Deepanshi1
use below script in onchange client script on field assignment group
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if(newValue==''){
g_form.clearValue('assigned_to');
}
//Type appropriate comment here, and begin script below
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:21 AM
Hi @Deepanshi1
I've written a simple On-change client script & it seems to be working as per your requirement.
Please find the attached screenshot for your reference & below is the code which can be used to clear Assigned to when Assignment group changes.
Please mark it as Accepted if it worked for you or feel free to reply so that I can check it furthermore.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(oldValue!=newValue)
{
g_form.clearValue('assigned_to');
}
//Type appropriate comment here, and begin script below