Skip to content

Commit 88401f2

Browse files
committed
created a separate file
created a separate file for onChange client script
1 parent 1cc5227 commit 88401f2

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**onChange Client Script on Change_Request form when CI changes */
2+
3+
function onchange(control, oldValue, newValue, isLoading) {
4+
if (isLoading || newValue == '') {
5+
return;
6+
}
7+
8+
var ga = new GlideAjax('getServiceDetails');
9+
ga.addParam('sysparm_name', 'getService');
10+
ga.addParam('sysparm_ci_sys_id', newValue);
11+
ga.getXML(callScriptInclude);
12+
13+
function callScriptInclude(response) {
14+
var answer = response.responseXML.documentElement.getAttribute("answer");
15+
16+
if (answer) {
17+
// Set the Business Service field with the service name returned
18+
g_form.setValue('business_service', answer);
19+
} else {
20+
// Optional: show a message if no service is found
21+
g_form.showFieldMsg('business_service', 'No linked Business Service found for this CI.', 'info');
22+
}
23+
}
24+
}

Server-Side Components/Script Includes/Business Service Fetch When CI Changes/scriptinclude.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,3 @@ getServiceDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
4141
});
4242

4343

44-
/**onChange Client Script on Change_Request form when CI changes */
45-
46-
function onchange(control, oldValue, newValue, isLoading) {
47-
if (isLoading || newValue == '') {
48-
return;
49-
}
50-
51-
var ga = new GlideAjax('getServiceDetails');
52-
ga.addParam('sysparm_name', 'getService');
53-
ga.addParam('sysparm_ci_sys_id', newValue);
54-
ga.getXML(callScriptInclude);
55-
56-
function callScriptInclude(response) {
57-
var answer = response.responseXML.documentElement.getAttribute("answer");
58-
59-
if (answer) {
60-
// Set the Business Service field with the service name returned
61-
g_form.setValue('business_service', answer);
62-
} else {
63-
// Optional: show a message if no service is found
64-
g_form.showFieldMsg('business_service', 'No linked Business Service found for this CI.', 'info');
65-
}
66-
}
67-
}

0 commit comments

Comments
 (0)