Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

Workflow status

 Post Reply Post Reply
Author
Ronald Wyman View Drop Down
New Member
New Member
Avatar

Joined: 06 Feb 2013
Posts: 5
Post Options Post Options   Quote Ronald Wyman Quote  Post ReplyReply Direct Link To This Post Topic: Workflow status
    Posted: 26 Sep 2018 at 10:50pm
We have a clients that process many workflows in a day and they would like us to write a function to set the status on many workflows at a time. Can you provide some code/pseudocode on how we this would be write this?

Thanks
Ron
Back to Top
Ronald Wyman View Drop Down
New Member
New Member
Avatar

Joined: 06 Feb 2013
Posts: 5
Post Options Post Options   Quote Ronald Wyman Quote  Post ReplyReply Direct Link To This Post Posted: 26 Sep 2018 at 10:51pm
We have clients that process many workflows in a day and they would like us to write a function to set the status on many workflows at a time. Can you provide some code/pseudocode on how we this would be write this?

Thanks
Ron
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2403
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 27 Sep 2018 at 1:22pm
Hi Ron,
I believe you mean set the status of many task instances at a time? Because the status of the workflow is always set internally by Workflow Studio depending on the flow. You can retrieve a list of task instances for a specified user like this:

var
  ATasks: TTaskInstanceList;
begin
  ATasks := TTaskInstanceList.Create(TTaskInstanceItem);
  try
    WS.TaskManager.LoadTaskInstanceList(ATasks, tfUser, 'username', true
{only incomplete tasks});
    {other options:
    WS.TaskManager.LoadTaskInstanceList(ATasks, tfUsers,
'user1,user2,user3', true );
    WS.TaskManager.LoadTaskInstanceList(ATasks, tfWorkIns, '23', true );
//To see tasks of workflow instance 23
    }
    if ATasks.Count > 0 then
      ShowMessage('User has pending tasks.')
    else
      ShowMessage('User doesn't have pending tasks.');

   // Iterate through ATasks collection to see the list of tasks
  finally
    ATasks.Free;
  end;
end;

Then for each task instance you can modify the status like this (TI is a TTaskInstance object):

TI.Status := ‘closed’; //set the status to a final status you want 
WorkflowStudio.TaskManager.SaveTaskInstance(TI);


Back to Top
Ronald Wyman View Drop Down
New Member
New Member
Avatar

Joined: 06 Feb 2013
Posts: 5
Post Options Post Options   Quote Ronald Wyman Quote  Post ReplyReply Direct Link To This Post Posted: 27 Sep 2018 at 1:47pm
Thanks for the reply Wagner,

"I believe you mean set the status of many task instances at a time? " Yes.

Is there a method to perform this work from the grid on the selected items?
Is there a way to determine what are the valid TI.Status are for a TaskInstance?

Thanks
Ron
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2403
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 27 Sep 2018 at 2:12pm
From the current builtin dialog there is no such functionality. But if you have a custom form, then of course you can add such code.
From the task instance, you can get the list of valid status 

TI.TaskDef.StatusList  // StatusList is a TStrings object
Back to Top
Wagner R. Landgraf View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2403
Post Options Post Options   Quote Wagner R. Landgraf Quote  Post ReplyReply Direct Link To This Post Posted: 27 Sep 2018 at 2:14pm
Correction, you should use

for I := 0 to TI.TaskDef.StatusCount - 1 do
  TI.TaskDef.StatusName;

You can also check if the status is a completion status (finalizes the task) by checking TI.TaskDef.StatusCompletion
Back to Top
Ronald Wyman View Drop Down
New Member
New Member
Avatar

Joined: 06 Feb 2013
Posts: 5
Post Options Post Options   Quote Ronald Wyman Quote  Post ReplyReply Direct Link To This Post Posted: 27 Sep 2018 at 2:39pm
Thanks I'll give it try...
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down