Skip to content

Commit 7f4e3c9

Browse files
Create UI Action script.js
UI action script
1 parent 34a7876 commit 7f4e3c9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Demo- OnClick function to execute
2+
function demo() {
3+
var ga = new GlideAjax('sn_hr_core.close_items');
4+
ga.addParam('sysparm_name', 'getRelatedItems');
5+
ga.addParam('sysparm_case_id', g_form.getUniqueValue());
6+
ga.getXMLAnswer(function(response) {
7+
// If there exist related items
8+
var items = JSON.parse(response);
9+
if (items.length > 0) {
10+
var msg = "This case has related items:\n";
11+
items.forEach(function(item) {
12+
msg += "- " + item.type + ": " + item.number + "\n";
13+
});
14+
msg += "\nDo you want to close them as well?";
15+
if (confirm(msg)) {
16+
// close current HR case
17+
g_form.setValue('state', '3');
18+
g_form.save();
19+
}
20+
} else {
21+
// If no related item is associated
22+
if (confirm("No related items found. Close this case?")) {
23+
g_form.setValue('state', '3');
24+
g_form.save();
25+
}
26+
}
27+
});
28+
}

0 commit comments

Comments
 (0)