aving a blast from Knowledge 12 this week! It’s been fun this year being able to relax a little bit more and take some more time to talk with people. I look forward to meeting more of you over the next couple of days.
Today, I’m writing in response to a user on the ServiceNow community, and a few users in the advanced admin course I was observing earlier in the week. In the advanced admin class, they show how you can click a UI action on the change form to show a workflow in progress. They also show you how you can view a timeline for a workflow context. These UI actions (and corresponding popups) can provide valuable information to both administrators and technicians to determine the status and process of a particular workflow. The only problem (in the case of the timeline) is that it can’t be accessed from the change directly. You have to navigate to the workflow context record first.
In this post I’ll show you how to create a UI action script to display a workflow timeline popup directly from any task form in the system.
If you’re familiar with the default UI action in the system, the code below should look familiar. It is initiated from the client, gets the sys_id of the workflow context, constructs a URL to the timeline, and then pops a new window up showing the timeline. The real trick in this case is getting the correct sys_id from the workflow context record. You should be able to create the following as a UI action on your task table. It will display for any itil user on a task that has an associated workflow.
Name: Show Workflow Timeline
Show Insert: False
Form link: True
Condition: !current.isNewRecord() && (new Workflow().hasWorkflow(current)) && gs.hasRole(‘itil’)
var wf = new GlideRecord('wf_context');
var url = new GlideURL('show_schedule_page.do');
var w = getTopWindow();
w.popupOpenFocus(url.getURL(), 'show_workflow_timeline', 950, 700, '', false, false);