THURSDAY, JANUARY 19, 2017

Show a Task Workflow Timeline

H

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.

Change Request Timeline

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.

‘Show Workflow Timeline’ UI Action
Name: Show Workflow Timeline
Table: Task
Order: 200
Show Insert: False
Client: True
OnClick: showTimeline();
Form link: True
Condition: !current.isNewRecord() && (new Workflow().hasWorkflow(current)) && gs.hasRole(‘itil’)
Script:

function showTimeline() {  
   var wf = new GlideRecord('wf_context');
   wf.addQuery('id', g_form.getUniqueValue());
   wf.query();
   if(wf.next()){
      var url = new GlideURL('show_schedule_page.do');
      url.addParam('sysparm_stack', 'no');
      url.addParam('sysparm_page_schedule_type', 'workflow_context');
      url.addParam('sysparm_timeline_history', wf.sys_id);
      var w = getTopWindow();
      w.popupOpenFocus(url.getURL(), 'show_workflow_timeline', 950, 700, '', false, false);
   }
}

4 Comments

Michele 16-05-2012, 07:14

I have created 2 New UI actions in a table I created. They are both Related Links. One is Show Worklow (this one works fine) and the other one is Show Timeline(this one does not work). I have tried the script in this page but it does not work. Any help would be great.

Reply
Mark Stanger 16-05-2012, 09:22

Can you recreate the issue on a SN demo instance and send me a link? It seems to work fine for me in my testing.

Reply
Ian 18-05-2012, 11:41

Might want to check the single quotes around ITIL in the condition line, they gave an error for me until I replaced them. Once changed it works for me.

Reply
Gwen Solis 29-01-2013, 01:25

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.

Reply

Leave a Reply


Latest Comments

  • David: It appears that I can hit sys_properties table with REST. This works, but I haven’t yet discovered the...
  • Mark Stanger: Hey David, It doesn’t surprise me that scoped apps have made this more difficult. I’m not...
  • David: Mark, do you have an example of how to do this in a scoped app? It seems there are many hoops to jump through...
  • Mark Stanger: The only possibility is to create a system property to override this in your application. Check out the...