- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
The following script is to create incident with 'short_description', 'Urgency' etc. The Virtual Agent is using this code to create incident.
I want to also add 'Impact' and 'Service_offering'. However, it did not work when I did the following:
-duplicate this script and create a new one;
-add 'impact' and 'service_offering' in line 6
-add new lines to set value of 'impact' and 'service_offering' between line 15 and line 16.
Please shed some light on how to achieve this.
System Definition>Script Includes>VACreateINCUtil
1 var VACreateINCUtil = Class.create();
2
3 VACreateINCUtil.prototype = {
4 initialize: function() {},
5
6 createIncident: function(caller, short_description, urgency, description, cmdb_ci) {
7 var incDetails = {};
8
9 // Create Universal Request if create ur with incident property is set to true
10 var universalgr = this.createUR();
11
12 var incGr = new GlideRecord("incident");
13 incGr.initialize();
14 incGr.setValue("caller_id", caller);
15 incGr.setValue("urgency", urgency);
16 incGr.setValue("short_description", short_description);
17 incGr.setValue("description", description);
18 incGr.setValue("contact_type", "virtual_agent");
19 incGr.setValue("cmdb_ci", cmdb_ci);
20
21 if (!gs.nil(universalgr))
22 incGr.setValue("universal_request", universalgr.sys_id);
23
24 incDetails.sysid = incGr.insert();
25 incDetails.incNum = incGr.getValue('number');
26
27 // Check if creation of incident is successful otherwise delete UR
28 if (!gs.nil(universalgr)) {
29 if (!gs.nil(incDetails.sysid))
30 this.updateUR(universalgr, incGr);
31 else // Delete UR if incident creation failed
32 this.deleteUR(universalgr);
33 }
34
35 return incDetails;
36 },
37
38 createUR: function() {
39 var create_ur = gs.getProperty("sn_itsm_va.com.snc.create_universal_request_with_incident");
40 if (create_ur == "true") {
41 if (new GlidePluginManager().isActive("com.snc.universal_request")) {
42 var universalgr = new GlideRecord("universal_request");
43 universalgr.initialize();
44 universalgr.insert();
45 return universalgr;
46 }
47 }
48 return;
49 },
50
51 updateUR: function(universalGr, incGr) {
52 // Creating new reference for universalGr to get latest values
53 var gr = new GlideRecord("universal_request");
54 gr.get(universalGr.sys_id);
55 gr.setValue("short_description", incGr.short_description);
56 gr.setValue("contact_type", "virtual_agent");
57
58 if (gs.nil(gr.getValue("primary_task")))
59 gr.setValue("primary_task", incGr.getUniqueValue());
60
61 gr.update();
62 },
63
64 deleteUR: function(universalGr) {
65 universalGr.deleteRecord();
66 },
67
68 type: 'VACreateINCUtil'
69 };
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Since Impact and Service Offering both failed together, the most likely root cause is:
You modified the Script Include But did not modify the VA Script Action / Flow Action / Script Step that invokes VACreateINCUtil.createIncident().
As a result, the new parameters are arriving as undefined, so nothing is populated on the Incident.
If you share the Virtual Agent script/action that calls VACreateINCUtil, I can tell you the exact code changes needed.
Some More Inputs -
Update Function Inputs Parameter List.
create corresponding VA variables for:Impact and Service Offerings.
Regards
RP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Since Impact and Service Offering both failed together, the most likely root cause is:
You modified the Script Include But did not modify the VA Script Action / Flow Action / Script Step that invokes VACreateINCUtil.createIncident().
As a result, the new parameters are arriving as undefined, so nothing is populated on the Incident.
If you share the Virtual Agent script/action that calls VACreateINCUtil, I can tell you the exact code changes needed.
Some More Inputs -
Update Function Inputs Parameter List.
create corresponding VA variables for:Impact and Service Offerings.
Regards
RP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
based on the script: System Definition>Script Includes>VACreateINCUtil
I've created a new script: VACreateINCUtilforITHelpDesk
I called it in the VA as below, but it is not working for 'impact'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hey @SonnyY
Did this work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You modified the Script Include But did not modify the VA Script Action / Flow Action / Script Step that invokes VACreateINCUtil.createIncident().
You're right about it. However, the parameters were defined ok. The issue occurred where the api was not defined correctly in the VA script. Please see below. Now that I have updated the API prefix, it worked perfectly. Many thanks,
