Form not submitted

nowitsvashu
Tera Guru

If incident tasks not close then incident also not close. 
I've write this client script for it and used script include also. 
But issue is when tasks are close completed then also form is not submitted.

function onSubmit() {
    var sysID = g_form.getUniqueValue();
    var submit = false;

    var ga = new GlideAjax('closeTask');
    ga.addParam('sysparm_name', 'checkTask');
    ga.addParam('sysparm_value', sysID);
    ga.getXMLAnswer(function(response) {
        if (response == 'true') {
            g_form.addErrorMessage("Task Incidents are not closed.");
            submit = false;
        } else {
            submit = true;
        }
    });

    return submit;
}
2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @nowitsvashu 

 

Plz chk the Incident property which move task to cancel if you try to close the Incident.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

swathisarang98
Giga Sage
Giga Sage

Hi @nowitsvashu ,

 

You can write a before update Business rule on Incident table and query to child table,

 

Here i am checking for child incident but according to your requirement please change the table name and query 

swathisarang98_0-1710008030865.png

swathisarang98_1-1710008040714.png

 

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

    var inc = new GlideRecord('incident');
    inc.addQuery('parent_incident', current.sys_id);//in child incident we have parent_incident field which stores parent number
    inc.addQuery('active',true);
    inc.query();
    if (inc.hasNext()) {
		gs.addInfoMessage('please close all child task before closing Parent incident');
		gs.info('inside if child');
		current.setAbortAction(true);

    }

})(current, previous);

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang