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

ricker
Tera Guru

@Yugandhar1,

It sounds like you want to require a close note and set the state on the Request when the last SC Task is closed skipped?

yes

BharathChintala
Mega Sage

@Yugandhar1 

write a onload client script on 'sc_req_item' table 

function onLoad() {
var id = g_form.getValue('sys_id');
var gar = new GlideAjax('checkSkipTasks');
gar.addParam('sysparm_name', 'getData');
gar.addParam('sysparm_id', id);
gar.getXML(getdata);
}

function getdata(trigger) {
var answer = trigger.responseXML.documentElement.getAttribute('answer');
if (answer == true) {
g_form.setMandatory('close_notes', true);
}
}

script Include: make sure client callable is true

var checkSkipTasks = Class.create();
checkSkipTasks.prototype = Object.extendsObject(AbstractAjaxProcessor, {

getData: function() {
var req = this.getParameter('sysparm_id');
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", id);
gr.addQuery('state',!= 7);
gr.query();
if(gr.hasNext()){
return false;
}else{
return true;
}
},
type: 'checkSkipTasks'
});

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

Hi Bharath,

 

I tried client script and script include but still it's not working. Can you please provide an alternative solution?