- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
I'm Forrest Falk, a ServiceNow Certified Master Architect (CMA). This is the second post in a series where I share practical insights from a CMA’s perspective and show how to build a custom skill that suggests a category based on an incident's short description and description. In each post, we will add more to our skill, covering everything from creating it to triggering it with a UI Action on a form to automating it with a flow.
Check out the previous posts in the series below:
Next we are going to continue updating our skill inputs and work on creating a tool node to grab the categories.
Now click after the first colon for the short description input. Just above the prompt in the top right you should see an “Insert inputs” button. Click that button and you should see:
Now select “Short Description”. You should see it type out {{short_description}} in the prompt. What that does is when we give the skill an input for the short_description, it will replace the “{{short_description}}” with the actual input provided.
Let’s now do that for the description row too. Click “Save” at the top and you should see the inputs turn blue. That means they are linked to an actual input now.
Alright, now that we have the short description and description as input, we just need the current categories. You should see a “Tool editor” tab at the top. Go ahead and click that tab and you should see the following:
In the tool editor, we can add, modify, and test different tools for our skills. In our case, we will want to add a tool to lookup the current categories on an incident. To do so we can click the “+” right above our skill prompt.
It will ask you what type of node to create, select “Tool node” and click “Add”:
Here you can see all the different types of tools from Flow Actions, to other skills to web searches and more. We are going to select “Script” and then click the “Configure tool” button.
I am going to name the script “getIncidentCategories” and click the “Write my own script” radio button. In the script window I am going to use the below script to lookup the incident categories. The script will check the sys_choice table for all categories related to incident. You could also add an additional query here to only return active records if you wish. Our script will return a string of categories in the format “<category_label_1>:<category_value_1>,<category_label_2>:<category_value_2>” so we can easily parse the categories later. I recommend before going to production to move your script into a script include so it can be shared system wide to allow for modular design.
function runScript(context) {
var choices = '';
var gr = new GlideRecord('sys_choice');
gr.addQuery('name', 'incident');
gr.addQuery('element', 'category');
gr.orderBy('sequence');
gr.query();
while (gr.next()) {
choices += '' + gr.getValue('label') + ':' + gr.getValue('value') + ',';
}
return choices;
})(context);
Once you have the script entered, go ahead and click “Continue”.
With writing our own script, there are no tool inputs needed so click “Continue” again.
For tool outputs, we will just be using the standard output variable. You can truncate your outputs if you think they will go over the token limits. In my case, the category list is short. Click “Continue”.
Join me in part 3 below to continue working on our custom skill. We will be continuing updating our skill's tool node.
Continue to part 3 here: Creating a Custom Skill with Now Assist Skill Kit - Part 3
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.