Skip to content

Commit 480ba52

Browse files
authored
Service now scripted soap service incident creation (#689)
* Create Scripted SOAP incident creation.js This is the Scripted SOAP service to create an incident from third party tools with all mandatory validations. * Create Readme.md I have created a scripted SOAP service for creation of incident with the help of third party tools, with all mandatory validations. My API will check the validations while creating the incidents from third party tool and it won't allow to submit the record untill all validations will pass.
1 parent ec6d993 commit 480ba52

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
I have created a scripted SOAP service for creation of incident with the help of third party tools, with all mandatory validations. My API will check the validations while creating the incidents from third party tool and it won't allow to submit the record untill all validations will pass.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
(function scriptedWebServiceOperation(request, response) {
2+
3+
var v1=checkMandatory(); // This function will check the all mandatory validations.
4+
if(v1==true){
5+
var grinc = new GlideRecord('incident');
6+
grinc.initialize();
7+
grinc.caller_id=request.Caller_id;
8+
grinc.short_description=request.Short_Description;
9+
grinc.cmdb_ci=request.CI;
10+
grinc.insert(); // It will insert the record, with provided values.
11+
response.Result='Incident Created';
12+
response.Sys_Id=grinc.sys_id; // It will return the sys_id in response body.
13+
response.Number=grinc.number; // It will return the incident number in response body.
14+
}else{
15+
response.Result=v1;
16+
}
17+
function checkMandatory() {
18+
if (request.Caller_id) {
19+
if (request.Short_Description) {
20+
if (request.Description) {
21+
if (request.CI) {
22+
var grci = new GlideRecord('cmdb_ci'); // These are the mandatory validations while submitting the request from client.
23+
grci.addQuery('name',request.CI);
24+
grci.addQuery('opertaional_status','1');
25+
if(grci.next){
26+
return true;
27+
}else{
28+
return 'CI not found or may be it is not in opperational state';
29+
}
30+
} else {
31+
return 'CI can not be blank';
32+
}
33+
} else {
34+
return 'Description can not be empty';
35+
}
36+
} else {
37+
return 'Short description can not be blank';
38+
}
39+
} else {
40+
return 'Caller Id can not be blank';
41+
}
42+
}
43+
44+
})(request, response);

0 commit comments

Comments
 (0)