- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 09:02 AM
This is the field in the Task table
When I try to create the breakdown source this field doesn't appear :
Also I just need the task type ( Incident, Request, Catalog Task and External Customer Support)
Any advice will be welcome
Solved! Go to Solution.
- Labels:
-
Dashboard
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2017 09:41 AM
Dennis,
I works perfectly for the Task table but when I try to add this break down to my view.( u_task_to_knowledge) I don't have the option to assign the task.type scrip to this view in the breakdown mapping.
Please advice me....
Regard
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 07:02 PM
Hey Luis, that's not where you specify what you want your breakdowns to be. The Breakdown Source are the things that you want to be able to pick as your breakdown in a list. In this case, you don't want to be able to pick a task, or you'd be saying, "Show me all the [whatevers] that are associated with INC0012345," for example. In your case, you want the things that will be your breakdowns to be tables ("Show me all the [whatevers] that are Incidents"), so your facts table should be Table [sys_db_object].
As for which field you should use, you want to use the field that will be mapped to the values stored in the table you'll be hitting against to record your data. This will almost always be the sys_id field, since all reference fields store the sys_id as as their reference value. The sys_db_object table is just a little different, however. The task type field doesn't actually reference the table's sys_id field, it references the name field.
However...
ServiceNow won't let you use the name field as your reference. I don't know why, maybe it's because it's not the primary key field, and it only will use primary keys. At any rate, the practical situation is that you must use the sys_id field. This will make it a bit harder to set up your automated breakdown, but it is what it is, so go ahead and create a breakdown source using sys_db_object as your table and sys_id as your field.
I created a breakdown source called Task Type. Here's a screenshot of what it should look like.
At this point, you might be tempted to go off and create a shiny new Automated Breakdown, but don't do that yet. Remember, your Task Type [sys_class_name] field stores the name of the table in it, not the sys_id, but your breakdown source looks at the sys_id of the table. You'll need a script to map the name to the sys_id for the breakdown source. To do that, you'll need to create a new script (under Automation > Scripts on the nav menu). I called mine Task.Type, but feel free to name it whatever you want. This next part is important, because if you forget it, you'll get errors in your log and you will drive yourself crazy trying to figure out why, so please make sure you do this: MAKE SURE in your script that you select Task type in the fields list in the Source section. This is because the script references the Task type [sys_class_name] field, and if you don't specify it here, your script will break in a very obscure and arcane way.
Here's the script you need to use to perform the mapping, and a screenshot showing the settings you need to configure in your script:
(function getTaskType() {
var grTable = new GlideRecord('sys_db_object');
return grTable.get('name', current.sys_class_name)
? grTable.getValue('sys_id')
: '';
})();
One more quick tip: You CANNOT use current.getValue('sys_class_name') here, because current isn't a GlideRecord like it is in most scripts. You MUST use current.sys_class_name. I figured that out the hard way, but I digress...
Okay, now you're ready to create your actual breakdown. Under Automated Breakdowns, create a new one. I called mine Task Type, but feel free to name it something else if you want to avoid confusion with the breakdown source. Specify the Breakdown source as Task Type (or whatever you called your source above), and save it.
Next, create your breakdown mapping. In the related list under Breakdown Mappings, create a new mapping using the Task [task] facts table. Don't specify a field, because you don't have a field that maps directly to your breakdown source. Instead, check the Scripted box, and select your Task.Type script that you created just above. Your breakdown mapping should look like this:
When all is said and done, this is what your breakdown should look like:
Now your breakdown should show up on any indicator based on a task table. Note that your breakdown will show up only on task tables even though other tables (such as CIs) have the sys_class_name column. The reason why is because you only have a mapping to the task table. If you want to be able to break down other tables, add a breakdown mapping for the table you want to see the breakdown for in the automated breakdown record above, making sure you specify Task.Type as the script to run on it. If you add a breakdown mapping on a parent table (such as cmdb_ci), it will apply to all of its extended tables as well (for example, cmdb_ci_server).
Breakdowns are probably one of the most difficult things to wrap your brain around in ServiceNow, and it took me some heavy duty cogitation on them to grok them. Just remember:
- The breakdown source is the source of what you want to show up in your breakdown list. Want to see choices in the sys_choice table, such as priority designations, states, or something like that? Then use sys_choice as your breakdown source. In this case, you want table names to show up in your breakdown list, so sys_db_object will be your breakdown source.
- If you have a one-to-one correspondence between the field in the table that is the basis of your indicator and the table that is your breakdown source (for example, the sys_id is stored in the priority field of the incident table, and the sys_id is the sys_choice breakdown source field), then you don't need a script, you can just pick the field in the table you're going to use for your indicator in the breakdown mapping.
- If you DON'T have a one-to-one correspondence between the field in the table that is the basis of your indicator and the table that is your breakdown source (for example: the table name is the value of the field in the task table, but the sys_id is the field in the breakdown source), you'll need a script that will map the breakdown source field to the indicator table field.
- The breakdown mappings establish the relationship between a breakdown and the breakdown source. If you want the breakdown to be visible to indicators using a table, you must have a breakdown mapping for that table or some table that it extends.
If you keep all that in mind, then you too can be a breakdown master. Here's some inspiration. Here's an indicator I created using the exact process described above:
Note how I created an Elements Filter called "Interesting Task Types" to limit what appears on the scorecard to only task types I want to see. If you know you'll never need other task types, you can also select the filter in the automated breakdown in the Default elements filter field. Here's a screenshot of my filter, feel free to customize if you want:
If this solves your issue, please be sure to mark the answer correct. If not, let me know where you're running into trouble and I'll try to help.
Regards,
--Dennis R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2017 01:34 PM
Hi Dennis,
I did exactly what you instruct to me but I'm getting the log error you mention:
Notes:
Instead of the Task table I am using a view u_task_to_knowledge that contains the task_type field from the Task table (sys_class_name).
Here what I have
Breakdown Source:
Script:
Automated breakdown:
Results:
Job Log Error above and this:
Here is my view structure :
I also tried with the field: tsk_sys_class_name instead of tsk2_sys_class_namebut I got the same errors results. (I had re-check everthing twice)
Coud you please advice me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2017 09:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2018 03:15 PM
Amazing - thank you!