Why is Workflow Timer Script is not firing?

Todd O
Tera Guru

I have a simple workflow that includes a timer activity.   I'm simply setting the answer to a value of 10 just for simple testing purposes. The problem is that the time just sits there and hangs. It never moves onto the next activity. The odd thing is that when I set it to zero, it works. But, any other value greater than zero and it sits and hangs. I'm hoping someone knows the solution. Thank you in advance.

Todd

answer = 10;

find_real_file.png

1 ACCEPTED SOLUTION

Your company's admin should have access to the Hi instance that we log issues, request enhancements, etc.



HI Customer Support Login


View solution in original post

12 REPLIES 12

Michael Fry1
Kilo Patron

I found a troubleshooting KB that might help:


Determining if busy scheduler is delaying workflow timers | Finding a timer in the scheduled job queue




Symptoms


  • Timer did not execute or failed
  • Timer stuck
  • Slow timers
  • Hung workflow
  • Workflow is not progressing
  • Stuck workflow with asynchronous wftimer <sysID>


Workflow timer


When a workflow timer is executed, it creates a scheduled job according to the parameters set in the timer workflow activity. The scheduled job is a simple script that fires a timer event into the workflow. The created job is identified as WFTimer + the sys_id of the executing activity.



Michael Fry1
Kilo Patron

Part 2 of KB:


Finding the executing activity for a timer




  1. On HI, navigate to Workflow > Live Workflows > Active Contexts.
    A
    list of running workflows appears.
  2. Find the workflow context containing the timer being investigated.
  3. Open the context.
  4. Select the Workflow Executing Activities related list.
  5. Select the timer being investigated.
  6. Right-click the header bar and select Copy sys_id.
    A number similar to this appears: 9d9d0633d733110043ea6f14ce61038d. This is the sys_id of the executing record. It is the record of the Scheduled Job containing the Timer that the callback script will fire the timer event into. Follow any instructions to copy sys_id.
  7. Navigate to System Scheduler > Scheduled Jobs > Scheduled Jobs.
  8. In the Search field type: WFTimer + the sys_id you copied.
    Your search item should look something like this:
    WFTimer9d9d0633d733110043ea6f14ce61038d.
  9. Click the Search icon.
    If the timer is still in the scheduled job queue, the timer has not been fired. If the workflow appears to be stuck and waiting for this timer, the workflow is still in the queue. The workflow picks up once the timer is picked up by the scheduler.
  • On the page, find System Overview.
  • If the scheduler backed up, Events Pending displays in red.



What to do if scheduler is backed up


  • Filter out all jobs in the Ready state.


The remaining jobs are currently running and occupying the scheduler. Examine the running jobs. If one or more jobs are not operating as expected and are blocking the timer unnecessarily, cancel the offending transactions using the following steps:


  1. Navigate to User Adminstration > All Active Transactions.
  2. Identify the offending transaction.
  3. Select the checkbox next to the transaction.
  4. In the choice list actions, click Selected Rows.
  5. Then click Kill.
    A series of messages explains that the transaction may not be terminated immediatey.
    After the offending jobs are cancelled, the scheduler picks up the next set of queued jobs, which should include any due or overdue WFTimer jobs that have been queued as Ready.



Thank you for the detailed resolution. I'm investigating this now. In the active workflow contexts within my CR, there is no entry for the timer whatsoever. I'm going to switch my timer activity to be based on a duration and see if that at least shows up.   I'll keep you posted and mark answer correct once I get further. I can then post final resolution that I find. Thanks.


Todd


Here is a follow up from my test.   Something must be wrong with our installation or something.



1. Scenario 1: When I base my timer from a script, ServiceNow does NOT create a scheduled timer activity for the timer whatsoever.   This is the root cause but I don't know why it's doing this.   Ideas?


2. Scenario 2: When I base my timer on a "user specified duration" (e.g., 1 minute), ServiceNow will correctly create a scheduled timer activity and things progress along as normal.  



Again, any ideas why our installation will NOT generate timer activity when we select a script and give it something simple like this? answer = 10; // 10 seconds



Thanks in advance.


Todd