- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 11:37 PM
Hello,
I am having requirement As an IT fulfiller I want to close an opened task in one click and to have my name automatically applied on "Assigned to" field if it is empty.
Here the Assigned to should be filled in automatically when closing the sc_task record if I am member of the Assignment Group. Can you please help me how can i achieve this.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 01:08 AM
Hi,
then do this
I assume the logged in user is member of that group
function closeTask(){
g_form.setValue('state', 3);
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
updateTask();
function updateTask(){
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", current.assignment_group);
gr.addQuery("user", gs.getUserID()); // add this line as extra query
gr.setLimit(1);
gr.query();
if (gr.next()) {
current.assigned_to = gr.user;
}
current.state = 3;
current.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:58 AM
Hi,
The Assigned(current.assigned_to) to is filling up with some random user from the Assignment Group, But it should be the closed person from that group.
what should be replaced for gr.user??
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 01:08 AM
Hi,
then do this
I assume the logged in user is member of that group
function closeTask(){
g_form.setValue('state', 3);
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'close_sc_task');
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
updateTask();
function updateTask(){
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", current.assignment_group);
gr.addQuery("user", gs.getUserID()); // add this line as extra query
gr.setLimit(1);
gr.query();
if (gr.next()) {
current.assigned_to = gr.user;
}
current.state = 3;
current.update();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader