Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Close Task Business Rule

tomaslindev
Mega Guru

Hello everyone,
I need that when closing a Task, the worknotes become mandatory and are sent to the corresponding RITM worknotes.
For this I have created these 2 Business rules that do not apply, any ideas.
Thanks in advance

 

BR 1:

When: before

Filter Conditions: state is closed complete

Insert

 

(function executeRule(current, previous /*null when async*/) {
    if (gs.nil(current.work_notes)) {
        gs.addErrorMessage('Work Notes are mandatory when closing a task.');
        current.setAbortAction(true);
    }
})(current, previous);

BR 2: 

When: after

Filter Conditions: State is Closed Complete

Insert

 

(function executeRule(current, previous /*null when async*/) {
    var ritm = new GlideRecord('sc_req_item');
    if (ritm.get(current.request_item)) {
        ritm.work_notes = ritm.work_notes + '\nTask ' + current.number + ' closed: ' + current.work_notes;
        ritm.update();
    }
})(current, previous);

 

 

0 REPLIES 0