Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Due to various reasons it can happen that a task on a system ends up without any user available to process it. This may happen because roles / groups that define assignees to a task are empty or the assignees were deleted. The following first script provided here identifies these tasks and prints them out in a JSON format. It . With the second script it is possible to reassign these tasks based on some rules. They can be downloaded from the bottom of this page.

The script scripts uses REST calls to communicate with the target system. If the target system returns an error status code, the error details will be printed on the command line.

Script 1: Identify tasks without any users

This script identifies tasks without any users and print them out in JSON.

Parameters

This script supports passing various parameters explained below.

...

creatorId (not set by default)
Filter parameter to search for processes started by a specific user. If empty, not set or null, this filter will be ignored and the query will filter for all available creators.

Prerequisites

At first, the script will check if the target system identified by parameters targetSystemIp and targetSystemPort is reachable and running. After that, it will be checked if the provided credentials username and password are valid on that system and if the user has the required privilege MANAGE_PROCESSES.

If not, the script will terminate with an appropriate error message.

Example

An example call of the script with target system localhost:8080 (set by parameter’s default values):

Code Block
languagebash
.\SearchTasksWithoutUser_v1-2v2.ps1 -userName "roger" -password "rabbit" -modelIds "951049FDF8E14100BE7D810A2F018177", "951049FDF8E14100BE7D810A2F018177"

With this call, processes are filtered for running processes (set by default) and started by a model with one of the passed IDs.

To save the output directly in a JSON file, use the ">" operator:

Code Block
languagebash
.\SearchTasksWithoutUser_v2.ps1 -userName "roger" -password "rabbit" > tasks.json

Example output

Code Block
languagejson
[
    {
        "ActivityId":  "37D6BEE1BFE84ECE9E10BDA0D385AB6F",
        "ModelName":  "EmptyRole",
        "ModelId":  "951049FDF8E14100BE7D810A2F018177",
        "Link":  "http://localhost/app/management/index.html#/processdetails/7C854FEAF9CA4AD89FA5653A7E5CF072",
        "ProcessName":  "EmptyRole 218",
        "ProcessId":  "7C854FEAF9CA4AD89FA5653A7E5CF072",
        "Reason":  "Empty groups or roles.",
        "ActivityName":  "actWorkItem"
    },
    {
        "ActivityId":  "3D4BE4E4140D4275A93789C1155C5577",
        "ModelName":  "LoopFlow",
        "ModelId":  "39B5B353A90141C9B4751E07344D97B8",
        "Link":  "http://localhost/app/management/index.html#/processdetails/2CA098BD1F9E4E428F7969567D3E6758",
        "ProcessName":  "LoopFlow 2",
        "ProcessId":  "2CA098BD1F9E4E428F7969567D3E6758",
        "Reason":  "Performer does not exist.",
        "ActivityName":  "Start"
    }
]

Every JSON output element contains an attribute Reason stating the reason why this task has no users as well as some more attributes.

Script 1 version history

SearchTasksWithoutUser_v1-2
  • .

ps1

Script Version

Date

Author

Supported core-service version

Description

Download

2.0

15th Mar 2024

A-Team

10.0 or higher

  • support for core-service version 10.0

View file
nameSearchTasksWithoutUser_v2.ps1

1.4

15th Mar 2024

A-Team

up to 9.x

  • JSON ouput improved

View file
nameSearchTasksWithoutUser_v1-4.ps1

1.3

12th Feb 2024

A-Team

  • user http session with target system will be stored and reused so that only one session will be used for the whole script execution instead of one sesson for every request

1.2

28th Nov 2023

A-Team

  • renamed parameter processState to processStates

  • If only one task can be found, it will still be printed out as a JSON array with one element. Before it was printed out as a single JSON element.

View file
name

1.1

10th Nov 2023

A-Team

  • implemented check if core-service is reachable and running

  • implemented check if provided user credentials are correct and if user has privilege MANAGE_PROCESSES

1.0

24th Oct 2023

A-Team

-

Script 2: Reassign identified tasks

This script loops through a JSON list of tasks and reassigns them based on some criterias.

Parameters

This script supports passing various parameters explained below.

The following four parameters are for connecting to the target system and are required to execute the script:

targetSystemIp (default: “localhost”)
IP address of the target system.

targetSystemPort (default: “8080”)
Port of the target system.

username (empty by default)
Name of the user who is authorized to perform the script's actions. In particular, this involves
the functional right MANAGE_PROCESSES.

password (empty by default)
Password of the provided user.

You have to provide a JSON list of tasks that can be iterated over. You have two options to do that:

  1. If you have a JSON file, you can pass the path to it with the following parameter.

inputFilePath (empty by default)
The path to the JSON file containing all your tasks.

  1. Call both scripts in a pipeline. Take a look at the Example section below for more information.

Prerequisites

At first, the script will check if the target system identified by parameters targetSystemIp and targetSystemPort is reachable and running. After that, it will be checked if the provided credentials username and password are valid on that system and if the user has the required privilege MANAGE_PROCESSES.

If not, the script will terminate with an appropriate error message.

Functions to reassign the tasks

This script provides some basic functions to reassign the tasks:

  • reassign all tasks to another user:

Code Block
languagebash
reassignTasks $tasks <user_id>

This function loops through all tasks and reassigns all of them to a user with the given ID.

  • reassign tasks based on a property value:

Code Block
languagebash
reassignTasksBasedOnProperty $tasks <property_name> <expected_value> <user_id>

This function loops through all tasks and reassigns a task to a user with the given ID if the property has the expected value. If not, this task will be skipped and not reassigned.

You can also specify a second user ID to which the task will be reassigned if the property has not the expected value:

Code Block
languagebash
reassignTasksBasedOnProperty $tasks <property_name> <expected_value> <user_id_if> <user_id_else>

If the task has no property with the given name, it will be skipped.

Please note that a task can only be reassigned based on a property that exists in your JSON list.

  • reassign tasks based on a variable value:

Code Block
languagebash
reassignTasksBasedOnVariable $tasks <variable_name> <comparison_operator> <expected_value> <user_id>

This function loops through all tasks and reassigns a task to a user with the given ID if the condition applies. If not, this script is not a task will be skipped and not reassigned.

You can pass the following comparison operators to the function: <, <=, =, >=, >

You can also specify a second user ID to which the task will be reassigned if the condition does not apply:

Code Block
languagebash
reassignTasksBasedOnVariable $tasks <variable_name> <comparison_operator> <expected_value> <user_id_if> <user_id_else>

If the task has no variable with the given name, it will be skipped.

Example

This script needs a list of tasks that should be reassigned. You can provide this list either ...

(1) by a JSON input file and using parameter inputFilePath:

Code Block
languagebash
.\ReassignTasks_v2.ps1 -userName "roger" -password "rabbit" -inputFilePath "tasks.json"

(2) by using a pipeline:

Code Block
languagebash
.\SearchTasksWithoutUser_v2.ps1 -userName "roger" -password "rabbit" | .\ReassignTasks_v2.ps1 -userName "roger" -password "rabbit"

By using a pipeline, you can search for tasks without any users and reassign them in one single command. The tasks found by the first script will be directly passed to the second script.

Example output

Script 2 version history

Script Version

Date

Author

Supported core-service version

Description

Download

2.0

15th Mar 2024

A-Team

10.0 or higher

  • support for core-service version 10.0

View file
nameReassignTasks_v2.ps1

1.0

24th Oct 2023

A-Team

up to 9.x

-

View file
nameReassignTasks_v1.ps1

Disclaimer

Please note that these scripts are not part of the product and is are not officially supported.

It uses They use non-public REST API methods that may change without prior notice. This page will be updated in case of API changes, but the maintenance of the script scripts and its derivatives in the field stays with its users.