- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2022 11:04 PM
Hi,
I have a requirement where the user are able to close the incident from the list view without the closure notes and closure codes.
I need to make sure they should fill the close notes and close codes before resolving or closing the ticket.
I have tried different methods including data policy but it was not working. Finally I wrote an onCell edit client script which is as follows,
if(newValue == 6 || newValue ==7){
alert("Closure notes and Configuration Item are mandatory");
saveAndClose = false;
}else{
saveAndClose = true;
}
callback(saveAndClose);
Problem with this is like after inserting the close codes and close notes from list view still it is showing that alert.
Can anyone help me with the above code , where I can check if the close code and close notes are empty.
Thanks in advance
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 12:50 AM
Hi Adarsh,
I have tried Data policy in my PDI & it is working fine. what condition are you adding in data policy?
For reference, check below screenshot.
Regards,
Harshal.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 02:00 AM
Hi
Use below Client Script:-
function onCellEdit(sysIDs, table, oldValues, newValue, callback) {
var saveAndClose = true;
//Type appropriate comment here, and begin script below
function callBack(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//alert(answer);
if (answer == 'false') {
alert("Closure notes and Configuration Item are mandatory");
saveAndClose = false;
callback(saveAndClose);
} else {
saveAndClose = true;
callback(saveAndClose);
}
}
if (newValue == 6 || newValue == 7) {
var ga = new GlideAjax('checkCIandCC');
ga.addParam('sysparm_name', 'getData');
ga.addParam('sysparm_sysid', sysIDs);
ga.getXML(callBack);
}
}
Script Include:-
var checkCIandCC = Class.create();
checkCIandCC.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getData: function() {
var sysID = this.getParameter('sysparm_sysid');
var gr = new GlideRecord("incident");
gr.addQuery("sys_id", sysID);
gr.query();
if (gr.next()) {
if (gr.cmdb_ci == '' || gr.close_code == '') {
return false;
} else return true;
}
},
type: 'checkCIandCC'
});
Working and tested in my PDI.
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Gunjan Kiratkar
Consultant - ServiceNow, Cloudaction
Rising Star 2022
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 02:08 AM
Hi,
You can achieve this easily with Data policy
what's not working with data policy?
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 03:23 AM
Hi
A data policy is already available but in inactive stage, if we make that active users are not able to create an incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 04:16 AM
Hi,
can you share that data policy configuration image?
you should give correct condition to make the fields mandatory only when State Changes to Closed or Resolved
OR
you can use before update BR on incident table and check if both the fields are empty and stop form submission and show error message
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2022 11:41 PM
Any update to this?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader