Automic Workload Automation

Expand all | Collapse all

Get the active executions list of a workflow

  • 1.  Get the active executions list of a workflow

    Posted May 17, 2018 10:03 AM

    Hi all,

     

    Can I get the running executions list of a workflow by querying the AE database. Our objective is to not run the workflow which is already being run by someone else from the team and also can I filter the list with the value from the variable that is present in the running workflow. For example, based on the value from Archive key 1 of the already running workflow, I would prompt the user with some text. Is that possible.

     

    Thanks in advance.

    Srujan.



  • 2.  Re: Get the active executions list of a workflow

    Posted May 17, 2018 03:01 PM

    Have you considered the "Tasks running parallel / Max number" option of the objects Attributes?  If you set this value to "1", then only one of those objects will be allowed to run at a time.



  • 3.  Re: Get the active executions list of a workflow

    Posted May 17, 2018 03:17 PM

    Hie Peter,

     

    I want the workflow to be executed multiple times at a time. Let me take an example, I have started running the workflow on customer A and if the other user would try to run the same workflow on same customer A, I should prompt the user not run this and then cancel the job. The customer value is stored in Archive key 1 of every workflow. hope you understand. Please let me know if you still have any questions.

     

    Thanks,

    Srujan.



  • 4.  Re: Get the active executions list of a workflow

    Posted May 17, 2018 03:33 PM

    You should be able to put this query in a SEC_SEQI type of variable;

     

    select distinct EH_Archive1
    from eh
    where eh_name = 'objectname'

     

    The EH table contains only those objects that are active.



  • 5.  Re: Get the active executions list of a workflow

    Posted May 17, 2018 03:37 PM

    This could also be solved with a static variable that holds the state for each user.  When the process starts it would add a row for that user to indicate it is active, and when the process ends it would remove that row.



  • 6.  Re: Get the active executions list of a workflow

    Posted May 17, 2018 04:27 PM

    Thanks for your time petwir  .I will try both and let you know if they work.

     

    Thanks,

    Srujan.



  • 7.  Re: Get the active executions list of a workflow

    Posted May 18, 2018 02:44 PM

    Hey petwir

     

    I tried with static variable and it worked perfect but how can I let the user know that the workflow is already being run on the same customer before cancelling the workflow. I have used the following script in the process tab of the workflow and with EXIT, it is abruptly ending.

     

    :IF GET_VAR(VARA.STATIC.ARCHIVEKEY1,&CUSTOMER#) = ''
    !:PUT_VAR VARA.STATIC.ARCHIVEKEY1,&CUSTOMER#, &$USER#
    !:ELSE
    !:EXIT 10
    !:ENDIF

     

     

    Regards,

    Srujan



  • 8.  Re: Get the active executions list of a workflow

    Posted May 18, 2018 03:53 PM

    One option is to use the SEND_MAIL() function right before the "EXIT 10".



  • 9.  Re: Get the active executions list of a workflow

    Posted May 18, 2018 03:56 PM

    Another option to consider is to put your IF statement inside of a loop and use a WAIT function so it pauses between loops.  The idea being that the object would wait until the coast is clear and would execute when the earlier instance completes.



  • 10.  Re: Get the active executions list of a workflow

    Posted May 18, 2018 05:29 PM

    I found a problem here. If the first user manually cancel the workflow in the middle or if any of the middle job gets aborted, how come the value in the variable object will be deleted. The deletion of the value is written in the end job of the workflow. If the same user tries to execute the workflow, then in this case it will not allow the user to run and will be terminated. 

     

    Any possible solution for this.

     

    Thanks,

    Srujan.



  • 11.  Re: Get the active executions list of a workflow

    Posted May 18, 2018 07:08 PM

    Agreed that is a problem, but not very frequent.

     

    You could write a timestamp value into the variable.  If this timestamp is too far into the past, then execute.  This would work like a hold-timeout feature.

     

    Or you could just leave it as it is, and if a process gets stuck, realize it will have to be unstuck manually by someone with the authority to modify the contents of the variable.

     

    There might be other options...



  • 12.  Re: Get the active executions list of a workflow

    Posted May 21, 2018 03:28 PM

    petwir However , I would like to go with the first one you suggested, using SQLI variable. But when I execute the query it is also picking up the values from non active tasks with status "FAULT_OTHER - Start impossible. Other error." Is this normal behavior?  I thought it would just pull values of the workflow with status "Active" only.

     

    Thanks,

    Srujan.



  • 13.  Re: Get the active executions list of a workflow

    Posted May 21, 2018 04:02 PM

    Add a WHERE clause that checks the column eh_status.  This column holds an integer value that represents the current state of the object.

     

    For instance a value of 1900 means "ENDED_OK" as per this documentation.  You will need to figure out what codes you want to select and/or exclude for your specific use-case;

    Automic