The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Need to make close note mandatory when sc task are closed skipped on Request item.

Yugandhar1
Tera Contributor

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.

Yugandhar1_0-1673959730931.png

Yugandhar1_1-1673959834368.png

Yugandhar1_2-1673959888921.png

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.

Yugandhar1_3-1673960124924.png

 

7 REPLIES 7

@Yugandhar1 @riya1814 

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.

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

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?

 

riya1814_0-1674056315097.png

 

 

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();
}