How to populate the assignment group when creating an incident through VA?

Katherine12
Kilo Contributor

This is my create request/incident script:

(function execute() {
    var caller = vaInputs.caller;
    var short_desc = vaInputs.short_description;
    var urgency = vaInputs.urgency;
    var desc = vaInputs.description;
    var cmdb_ci = vaInputs.cmdb_ci;
    var assignment_group = vaInputs.assignment_group;

     if (!gs.nil(caller) && !gs.nil(short_desc)) {
        var incDetails = new sn_itsm_va.VACreateINCUtil().createIncident(caller, short_desc, urgency, desc, cmdb_ci, assignment_group);
        vaVars.inc_sysid = incDetails.sysid;
     }
     
})()

However, upon testing, the assignment group isn't filled when an incident is created. Any recommendations?

1 ACCEPTED SOLUTION

i've never seen that script includes before and even peeking at it, not sure about it - particularly whatever a "Universal Request" (UR) is and how it's used.

I just have a single "Create Incident" topic block and the crux of the topic block is just a script action, close to what you have, but mainly missing the record initialization and insertion. You can do a lot more useful things in the topic block (like adding attachments) and in the script itself (i.e. dynamic routing based on the CI's support group), but this is the core of it:

    var incident = new GlideRecord('incident');
    incident.initialize();
    incident.caller_id = vaInputs.caller;
    incident.sys_created_by = vaInputs.user;
    incident.short_description = vaInputs.short_description;
    incident.assignment_group = vaInputs.assigment_group;
    incident.cmdb_ci = vaInputs.cmdb_ci;
    incident.urgency = vaInputs.urgency;
    incident.impact = vaInputs.impact;
    incident.contact_type = 'virtual_agent';
    incident.comments = vaInputs.comments;
    incident.incident_state = vaInputs.state;  
    //Save this incident as a variable to use to display it
    vaVars.incident = incident.insert();
    //Link this incident to the Interaction
    vaSystem.attachRecordToConversation('incident',vaVars.incident);

View solution in original post

6 REPLIES 6

Mark Roethof
Tera Patron
Tera Patron

Hi there,

You are using a Script Include, which does not support an input for Assignment Group. See the Script Include itself:

Line 6 for example:

createIncident: function(caller, short_description, urgency, description, cmdb_ci) {

No assignment_group.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP

---

LinkedIn
Community article, blog, video list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Thank you! Is there any way to implement this functionality (add assignment group) in a different way?

 

i've never seen that script includes before and even peeking at it, not sure about it - particularly whatever a "Universal Request" (UR) is and how it's used.

I just have a single "Create Incident" topic block and the crux of the topic block is just a script action, close to what you have, but mainly missing the record initialization and insertion. You can do a lot more useful things in the topic block (like adding attachments) and in the script itself (i.e. dynamic routing based on the CI's support group), but this is the core of it:

    var incident = new GlideRecord('incident');
    incident.initialize();
    incident.caller_id = vaInputs.caller;
    incident.sys_created_by = vaInputs.user;
    incident.short_description = vaInputs.short_description;
    incident.assignment_group = vaInputs.assigment_group;
    incident.cmdb_ci = vaInputs.cmdb_ci;
    incident.urgency = vaInputs.urgency;
    incident.impact = vaInputs.impact;
    incident.contact_type = 'virtual_agent';
    incident.comments = vaInputs.comments;
    incident.incident_state = vaInputs.state;  
    //Save this incident as a variable to use to display it
    vaVars.incident = incident.insert();
    //Link this incident to the Interaction
    vaSystem.attachRecordToConversation('incident',vaVars.incident);

Val8
Tera Contributor

Hi there,

 

I am trying to do something similar and I'm also trying to stay OOB as much as possible. I have asked the user to choose the assignment group using the Static choice list user input property. That value comes across as string. The assignment group field on the incident is more of a select box. I don't seem to be able to dot walk to the table so I can assign a specific value from that table when using the choice list input property.  

The only variables that appear on the js prompt list are those listed as VA Inputs on the previous Topic, so my variable isn't available to the Create Incident Topic. I've tried declaring the variable and setting it on the Create Incident Topic Block at the bottom, under Node Conditions, but that doesn't seem to be passed either. 

I don't seem to be able to declare a js global variable in the dropdown code sections available inside the topic block either (var value  or window.value).

 

 

Any suggestions are welcome please.