You are viewing limited content. For full access, please sign in.

Question

Question

Bulk Delete Business Process Instances by User Assign To

asked on May 20, 2024

Hey all,

The Monitor tasks page allows you to search for tasks assigned to a particular user and re-assign those tasks in bulk to another user.  It doesn't, however, appear to allow bulk deletion of those tasks.  The instance page allows bulk deletion but you can't filter by user assign to.  Is there a way to delete all of a user's tasks?

0 0

Replies

replied on May 20, 2024

The monitor page requires all instances to be stopped in order to be deleted, so you can filter by status and terminate all in progress instances first and then remove the status filter and delete all completed instances.

1 0
replied on May 21, 2024

But, the Monitor/Instances page where you can stop and delete instances does not allow you to sort by column (i.e. Assigned to) so there's no way to isolate the one user I'm trying to stop/deletes instances for.

0 0
replied on May 21, 2024 Show version history

I believe you can search by their name.  Apply what filters you can, then search to further limit the results.

0 0
replied on May 21, 2024

Unfortunately, the search on Monitor/Instances appears to only search in the Instance name column.  

0 0
replied on May 21, 2024

Have you enabled the column to show whom the instance is currently assigned to?  I'm pretty sure the search includes the column if it is enabled to be displayed.

0 0
replied on May 21, 2024

Yeah, I'm displaying the "Assigned to" column but typing a value in the search box is only finding matches in the "Instance" column.

0 0
replied on May 21, 2024

Hmm it looks like you may be right here. I do have ongoing research into enhancements to the task re-assignment and overall task management. I'll make sure to include this type of use case to that list so thank you for posting!

 

Someone may have a workaround for you at the DB level 

1 0
replied on May 21, 2024 Show version history

Yeah, a SQL script would work as well.  I've got a SQL script that deletes instances by BPInstanceID.  I just need one to retrieve a list of BPInstanceIDs for tasks assigned to particular users.

 

0 0
replied on May 21, 2024

This is a very careful line to walk.

As far as helping identify instances assigned to certain users, then I do have a database view that I have shared here on LFAnswers before, that (almost) approximates the information on the Monitor page.  You can use that pretty easily to search for instances assigned to certain users.

That said - I do not have a script to edit statuses or delete instances based on this information - I would never advise anyone to take steps like that, far too much can go wrong.  If you decide to proceed with something like that, I strongly advise you make a back-up of your database first.  But mostly my advise is do not do it, just do not do it, it's too big of a risk.

That said...  Here's the query that I use for the View.  Adding a View to the database isn't harmful, and this is useful for lots of situations, so I'm happy to share.  Note that the biggest differences between how things look in this query and the Monitor page are that occassionally reassigned items show in the query for both the prior owner and the reassigned owner, and I've never been able to figure that out, and tasks assigned to multiple individuals show once on the results for each assignee instead of being grouped together.

SELECT        [Process Name], [Instance name], [Started by], [Last updated], [Assigned to], [Assigned to (username)], [Assigned to (email)], [Current step], [Step start date], [Start date], [Instance ID], [Step due date]
FROM            (SELECT        instance.bp_name AS [Process Name], instance.title AS [Instance name], CASE WHEN start_user.displayname LIKE '%WORKFLOW%' THEN 'Workflow' ELSE start_user.displayname END AS [Started by], 
                                                    instance.lastacted_date AS [Last updated], CASE WHEN bp_worker_resume.status = 5 AND assigned_user_snapshot.displayname IS NOT NULL 
                                                    THEN assigned_user_snapshot.displayname WHEN bp_worker_resume.status = 5 AND assigned_user_snapshot.displayname IS NULL 
                                                    THEN assigned_user_record.displayname WHEN bp_worker_resume.status = 2 THEN assigned_user_snapshot.displayname WHEN assigned_user_team_snapshot.displayname IS NULL AND 
                                                    teams.name IS NOT NULL THEN CONCAT(teams.name, ' (Listing the Team Manager)') WHEN assigned_user_team_snapshot.displayname IS NULL 
                                                    THEN teams.name WHEN bp_worker_resume.status = 1 THEN assigned_user_team_snapshot.displayname END AS [Assigned to], CASE WHEN bp_worker_resume.status = 5 AND 
                                                    assigned_user_snapshot.username IS NOT NULL THEN assigned_user_snapshot.username WHEN bp_worker_resume.status = 2 AND assigned_user_snapshot.username IS NOT NULL 
                                                    THEN assigned_user_snapshot.username WHEN assigned_user_team_snapshot.displayname IS NULL AND team_users.username IS NOT NULL 
                                                    THEN team_users.username WHEN bp_worker_resume.status = 1 AND assigned_user_team_snapshot.username IS NOT NULL 
                                                    THEN assigned_user_team_snapshot.username ELSE 'NOT ASSIGNED TO USER' END AS [Assigned to (username)], CASE WHEN bp_worker_resume.status = 5 AND 
                                                    assigned_user_snapshot.displayname IS NOT NULL AND assigned_user_snapshot.email IS NOT NULL THEN assigned_user_snapshot.email WHEN bp_worker_resume.status = 5 AND 
                                                    assigned_user_snapshot.displayname IS NULL AND assigned_user_record.email IS NOT NULL THEN assigned_user_record.email WHEN bp_worker_resume.status = 2 AND 
                                                    assigned_user_snapshot.email IS NOT NULL THEN assigned_user_snapshot.email WHEN assigned_user_team_snapshot.displayname IS NULL AND team_users.email IS NOT NULL 
                                                    THEN team_users.email WHEN bp_worker_resume.status = 1 AND assigned_user_team_snapshot.email IS NOT NULL 
                                                    THEN assigned_user_team_snapshot.email ELSE 'NOT ASSIGNED TO USER' END AS [Assigned to (email)], CASE WHEN bp_worker_resume.step_name IS NOT NULL 
                                                    THEN bp_worker_resume.step_name ELSE bp_steps.name END AS [Current step], CASE WHEN bp_worker_resume.assign_date IS NOT NULL 
                                                    THEN bp_worker_resume.assign_date ELSE bp_worker.update_date END AS [Step start date], instance.start_date AS [Start date], instance.bp_instance_id AS [Instance ID], 
                                                    bp_worker_resume.due_date AS [Step due date]
                          FROM            dbo.cf_bp_main_instances AS instance LEFT OUTER JOIN
                                                    dbo.cf_user_snapshot AS start_user_snapshot ON start_user_snapshot.id = instance.user_snapshot_id LEFT OUTER JOIN
                                                    dbo.cf_users AS start_user ON start_user.user_id = start_user_snapshot.user_id LEFT OUTER JOIN
                                                    dbo.cf_bp_worker_instances AS bp_worker ON bp_worker.bp_instance_id = instance.bp_instance_id LEFT OUTER JOIN
                                                    dbo.cf_bp_steps AS bp_steps ON bp_steps.step_id = bp_worker.current_step_id AND bp_steps.process_id = bp_worker.current_process_id AND (bp_steps.step_type = 'catchEvent' OR
                                                    bp_steps.step_type = 'serviceTask') AND bp_steps.is_deleted = 0 LEFT OUTER JOIN
                                                    dbo.cf_bp_worker_instnc_to_resume AS bp_worker_resume ON bp_worker_resume.worker_instance_id = bp_worker.instance_id LEFT OUTER JOIN
                                                    dbo.cf_bp_worker_instance_history AS bp_worker_history ON bp_worker_history.instance_id = bp_worker.instance_id AND (bp_worker_history.status = 'assigned' OR
                                                    bp_worker_history.status = 'reassigned') AND bp_worker_resume.resume_id = bp_worker_history.assigned_resume_id AND bp_worker_resume.owner_snapshot_id IS NULL LEFT OUTER JOIN
                                                    dbo.cf_user_snapshot AS assigned_user_snapshot ON assigned_user_snapshot.id = bp_worker_resume.owner_snapshot_id LEFT OUTER JOIN
                                                    dbo.cf_users AS assigned_user_record ON assigned_user_record.username = assigned_user_snapshot.username LEFT OUTER JOIN
                                                    dbo.cf_user_snapshot AS assigned_user_team_snapshot ON assigned_user_team_snapshot.id = bp_worker_history.target_snapshot_id LEFT OUTER JOIN
                                                    dbo.teams AS teams ON (teams.id = bp_worker_resume.team_id OR
                                                    bp_worker_resume.team_id IS NULL AND teams.id = bp_worker_history.team_id) AND bp_worker_resume.owner_snapshot_id IS NULL LEFT OUTER JOIN
                                                    dbo.team_members AS team_members ON team_members.team_id = teams.id AND team_members.member_rights = 3 AND team_members.leave_date IS NULL LEFT OUTER JOIN
                                                    dbo.cf_users AS team_users ON team_users.user_id = team_members.user_group_id
                          WHERE        (instance.status = 1) AND (bp_worker.status <> 6) AND (bp_worker_resume.status = 5 OR
                                                    bp_worker_resume.status = 1 OR
                                                    bp_worker_resume.status = 2) AND (bp_worker_resume.assign_date IS NOT NULL) AND (bp_steps.step_type IS NULL OR
                                                    bp_steps.step_type = 'catchEvent') OR
                                                    (instance.status = 1) AND (bp_worker.status <> 6) AND (bp_worker_resume.assign_date IS NOT NULL) AND (bp_steps.step_type IS NULL OR
                                                    bp_steps.step_type = 'catchEvent') AND (bp_steps.step_id IS NOT NULL) OR
                                                    (instance.status = 1) AND (bp_worker.status <> 6) AND (bp_worker_resume.status = 5 OR
                                                    bp_worker_resume.status = 1 OR
                                                    bp_worker_resume.status = 2) AND (bp_steps.step_type IS NULL OR
                                                    bp_steps.step_type = 'catchEvent') AND (bp_steps.step_id IS NOT NULL) OR
                                                    (instance.status = 1) AND (bp_worker.status <> 6) AND (bp_steps.step_type IS NULL OR
                                                    bp_steps.step_type = 'catchEvent') AND (bp_steps.step_id IS NOT NULL) AND (bp_steps.step_id IS NOT NULL) OR
                                                    (instance.status = 1) AND (bp_worker.status = 3) AND (bp_steps.step_type = 'serviceTask')) AS subquery
GROUP BY [Process Name], [Instance name], [Started by], [Last updated], [Assigned to], [Assigned to (username)], [Assigned to (email)], [Current step], [Step start date], [Start date], [Instance ID], [Step due date]

 

If you add that as a View on the database, and then create a SELECT query from the View, you should be able to tease out all of the instances with tasks assigned to your specific user.  You may then want to also take the resulting instances IDs from that, and search those against the view just to double check that no other users are included in the task assignments on those instances.

1 0
replied on May 21, 2024

Thank you Matthew for the query, I've turned it into a view.  We do have daily backups, but  I've taken your stern advice and decided not to delete any instances.  The view will still be very useful though.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.