Need to make close note mandatory when sc task are closed skipped on Request item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2023 04:55 AM
Hi
We had requirement like when last task of sc_task state to closed skipped the sate should not change and error should display like fill close notes should be mandatory on req item. we tried BR and UI polices we are getting output like sc_task is closed skipped and Request state wont change to closed skiped once we change the state of request to closed skipped then work notes showing mandatory. see below screen shot for reference.
when i change last task to closed skip its not showing close notes mandatory but also request state is not changed to closed skip and close note not showing mandatory.
Now when i change request state to closed skip the close note will mandatory. But our requirement is when last task is closed skipped the state should not change and need to show close note mandatory on req. Please help who can we achieve. For reference i am attaching workflow also.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 07:30 AM
So, The script I gave will work only for making Close notes mandatory. Once you update last task to close skip and reload the request item form then you will see close notes as mandatory.
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2023 08:01 AM
You can refer to the below screenshot close notes field is not getting mandatory after closing the task. Can we make close notes mandatory through workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2023 03:26 AM
We already have one business rule working for task table we tried but it's not giving the expected results. (for reference see below script)
current.active = false;
current.work_end = nowDateTime();
current.business_duration = gs.calDateDiff(current.work_start.getDisplayValue(),current.work_end.getDisplayValue(),false);
var flag=0;
var gr_tsk = new GlideRecord("sc_task");
gr_tsk.addQuery('request_item', current.request_item);
gr_tsk.addQuery('state','3');
gr_tsk.query();
if (gr_tsk.next()){
flag =1;}
var gr_t = new GlideRecord("sc_task");
gr_t.addQuery('request_item', current.request_item);
gr_t.addQuery('state','NOT IN', '3,7'); // Not closed complete ,closed skipped
gr_t.query();
if(!gr_t.next()){
updateRITMState();}
function updateRITMState(){
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.request_item);
gr.addQuery('stage','!=','waiting_for_approval');
gr.query();
if(gr.next()){
if (flag == 1){
var notes = gr.getValue('close_notes').toString();
var a = notes.length;
if(a)
gs.log("Lenght is:"+a);
current.setAbortAction(true);
gs.addErrorMessage("Fill the close notes");
} else if(a>1)
gr.state = 3;
}
else{
gr.state = current.state;
}
gr.update();
}