Assignment group mandatory

Shrabanti
Tera Contributor

Hello Team
In my servicenow instance when we closed sc task after that ritm automatically get closed.
but i want if assignment group is empty ritm will never close and it will abort that action.
can u please help me with that.

4 REPLIES 4

Arun_Manoj
Mega Sage

hi @Shrabanti ,

Configure the Business Rule:

Table: Select sc_task.

When to run: Set the conditions under which the rule should run:

     When: After

Insert: Unchecked

Update: Checked

Delete: Unchecked

 

Add a condition to check if the state of the task is being set to closed.

 
current.state.changesTo('closed')
 
Script:
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
if (JSUtil.nil(ritm.assignment_group)) {
gs.addErrorMessage("Cannot close RITM as Assignment Group is empty.");
current.setAbortAction(true);
}
}
})(current, previous);
 
Mark it as helpful, if the solution is fine
 
Thanks
Arun

 

SN_Learn
Kilo Patron
Kilo Patron

Hi @Shrabanti , You can write a business rule on sc_task table to check the assignment group of RITM when the sctask is getting closed, if it is empty then abort the action.

 

SN_Learn_0-1721198694215.png

 

SN_Learn_1-1721198715002.png

 

(function executeRule(current, previous /*null when async*/ ) {

    var checkRITMGrp = new GlideRecord('sc_req_item');
    if (checkRITMGrp.get(current.request_item)) {
        if (checkRITMGrp.assignment_group == '' || checkRITMGrp.assignment_group == NULL) {
            gs.addErrorMessage('Task cannot be closed as RITM(s)Assignment Group is empty.');
            current.setAbortAction(true);
        }
    }

})(current, previous);

 

Result:

SN_Learn_2-1721198825302.png

 

 

 

Mark this as Helpful / Accept the Solution if this helps

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Community Alums
Not applicable

Hello @Shrabanti ,

Requested Item is automatically closed after all sc tasks get closed. It is the Out of the box functionality. If you wanted as your requirement, you need to over write Out of the box functionality.

 

Mark my answer helpful and correct, if it helps you

Thank you

 

Sri Harsha2
Tera Expert

Hello @Shrabanti ,

Write a Before BR on catalog task table(sc_task) with the condition as "assignment group changes to closed complete",

and follow the code as belowScreenshot (1280).pngScreenshot (1281).png