diff --git a/Integration/Scripted SOAP Incident Creation/Readme.md b/Integration/Scripted SOAP Incident Creation/Readme.md new file mode 100644 index 0000000000..364dd1e182 --- /dev/null +++ b/Integration/Scripted SOAP Incident Creation/Readme.md @@ -0,0 +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. diff --git a/Integration/Scripted SOAP Incident Creation/Scripted SOAP incident creation.js b/Integration/Scripted SOAP Incident Creation/Scripted SOAP incident creation.js new file mode 100644 index 0000000000..4b222ff805 --- /dev/null +++ b/Integration/Scripted SOAP Incident Creation/Scripted SOAP incident creation.js @@ -0,0 +1,44 @@ +(function scriptedWebServiceOperation(request, response) { + + var v1=checkMandatory(); // This function will check the all mandatory validations. + if(v1==true){ + var grinc = new GlideRecord('incident'); + grinc.initialize(); + grinc.caller_id=request.Caller_id; + grinc.short_description=request.Short_Description; + grinc.cmdb_ci=request.CI; + grinc.insert(); // It will insert the record, with provided values. + response.Result='Incident Created'; + response.Sys_Id=grinc.sys_id; // It will return the sys_id in response body. + response.Number=grinc.number; // It will return the incident number in response body. + }else{ + response.Result=v1; + } + function checkMandatory() { + if (request.Caller_id) { + if (request.Short_Description) { + if (request.Description) { + if (request.CI) { + var grci = new GlideRecord('cmdb_ci'); // These are the mandatory validations while submitting the request from client. + grci.addQuery('name',request.CI); + grci.addQuery('opertaional_status','1'); + if(grci.next){ + return true; + }else{ + return 'CI not found or may be it is not in opperational state'; + } + } else { + return 'CI can not be blank'; + } + } else { + return 'Description can not be empty'; + } + } else { + return 'Short description can not be blank'; + } + } else { + return 'Caller Id can not be blank'; + } + } + +})(request, response);