Skip to main content
Matrix42 Self-Service Help Center

Automation Workflow Activities Example

Example 1 - Replace in Assignments Action

The example is based on a build in feature which allows the replacement of a device or object in multiple assignments. It is based on an Action in the UI and uses a wizard to gather the required information. The result is handed over to a workflow using the activity "Add/Remove Devices to/from Assignments" and "Add/Remove Objects to/from Assignments".

The Action "Replace in Assignments" which is visible on devices or UEM objects which are assigned to at least one assignment can be reviewed in Administration -> User Interface -> Actions.

Replace_in_Assignments_Action.png

The wizard which opens after the action is clicked can be reviewed in Administration -> User Interface -> Layouts -> Wizards.

Replace Device Wizard Overview.png

The Wizard has three pages. The first wizard page shows the assignments allows to select in which ones the new device(s) should be added. The second allows to select the devices which should be added to the assignments. The third is a summary.

Replace Device Wizard.png

After finishing the wizard the workflow "Replace device in assignments" is initiated with the data provided by the wizard.

Replace_Device_WF.png

The workflow uses one activity which removes the initial device from the list of assignments and adds the newly selected devices to the list of assignments.

Example 2 - Automatically Assign NEW Computers

This example use case will add each new computer which name starts with FFM and is managed by Empirum to the UEM Assignment “Frankfurt” automatically.

It is based on a compliance rule which triggers a workflow.

As a prerequisite the user should have basic knowledge in Compliance Rules, Workflows and the Workflow Studio handling.

See also in the online help for general information:

Create new workflow in workflow studio

Start the Workflow Studio in Administration -> Services & Processes -> Workflows select “Workflow Studio”.

Use the Template “Compliance Rules – WF Template” to start with a new workflow which can be triggered by a compliance rule.

new_wf_compliance_rule.png

Name “FFM to Frankfurt”.

wf_properties.png

Add Variables:

  • Add a variable "DeviceCollection" of type "List<Guid>".
    • Select “Browse…” on Variable Type and search for “list”.SCR-20230321-n5x.png
    • Select for Type Name “System.Collections.Generic.List<T>”.SCR-20230321-n42.png
    • Select “System.Guid” in the sub field by searching for “guid” in the browse window.
      SCR-20230321-n58.png
    • Add “New List (of GUID)” text in default value field.
      SCR-20230321-n6h.png
      The variable is used as the list of devices and needs to be initialized by using the default value.
  • Create a variable “GroupID” of type “System.Guid”.
    SCR-20230321-n9q.png

Add Argument

Add the following argument:

  • Name = ObjectContexts
  • Direction = In
  • Argument Type – use browse and search compliance rule. Select the entry below and make sure the [] is at the end.

SCR-20230321-nd0.png

Add Activities

Drag the following Activities from the library to the workflow:

  • ForEach
  • Get Assignment by Name
  • Add/Remove Devices to/from Assignment

WF_Overview.png

Adding the devices provided by the compliance rule with a for each activity

  • Double-Click on “ForEach” activity.
  • Delete the FlowChart activity and add the AddtoCollection activity.
    for_each.png
    • Select the “AddToCollection” activity.
      add_to_collection.png
    • Enter “DeviceCollection” in “Collection”.
    • Enter “item.id” in Item.
    • Select “TypeArgument” as “System(GUID)”.

Configure activity “Get Assignment by Name”

get_ass_by_name.png

In properties:

  • Enter “Frankfurt” as Group Name.
  • Enter “GroupID” in Group ID.

Configure activity “Add/Remove Devices to/from Assignment”.

add_devices.png

In properties:

  • Enter “DeviceCollection” in “Added Device IDs”.
  • Enter “GroupID” in Group ID.

Finish Workflow

  1. Save the Workflow.
  2. Check in.
  3. Release.

Compliance Rule

The compliance rule triggers the workflow when new computers are added which match the selected conditions.

Add a new compliance rule in Administration -> Services & Processes.

Provide a name like “UD_Add FFM computers to Frankfurt” where the “Ud_” is a prefix for customer defined compliance compliance rules.

Description: Adds new computers which name starts with FFM via workflow to the UEM assignment group "Frankfurt".

Compliance_Rule.png

  • Select “Computer (SPSComputerType)” as Configuration Item.
  • Select “Conditions”.
  • As “Condition type” select “Create an Object”.
  • Select the conditions:
    • Computer.ManagedBy (Managed By) EQUALS “Empirum”
    • Computer.Name (Name) LIKE “FFM%”
  • Select “Processing” to change the processing options.
  • Select the option “Process the compliance rule events for the respective objects conjointly [especially for import/mass changes of objects]”.
  • Select “Actions”.
  • Select “+” and “Start Workflow” from the list.
  • Select “Workflow Details” and chose the workflow “Assign FFM computers to Frankfurt”.
  • Select “Finish”.
  • Select “Save”.

To test the use case create a new computer which name starts with FFM. The compliance rule will run each minute and triggers the workflow.

Example 3 - Automatically assign Computers based on Location

This example ensures that all devices which have the location "Frankfurt" are assigned to the Frankfurt Assignments but removes them if they do not belong to Frankfurt anymore.

It is based on a workflow which is called by an engine activation on a given schedule.

Create an assignment "Frankfurt"

Create new Workflow

  • Create a new workflow based on the template "Engine Activation" with the name "Update Frankfurt Assignments".
  • Add the workflow activity "Get Assignment by Name" and use "Frankfurt" as expression. As output create the predefined variable.
  • Add the workflow activity "Get Devices by Expression" and use the following expression to get the list of GUIDS for all devices which belong to Frankfurt location but are not assigned to the assignment "Frankfurt":
    • "RelatedSPSCommonClassBase.Location.Name='Frankfurt' AND RelatedSPSComputerClassBase.GroupAssignments[Name is NULL or Name <> 'Frankfurt']"
    • Use the predefined variable and add "_new" as a suffix as output (GetDeviceIdsByExpressionActivity_DevicesIDs_new).
  • Add a second workflow activity "Get Devices by Expression" and use the following expression to get the list of GUIDS for all devices which not belong to Frankfurt location but are assigned to the assignment "Frankfurt":
    • "RelatedSPSCommonClassBase.Location.Name<>'Frankfurt' AND RelatedSPSComputerClassBase.GroupAssignments[Name='Frankfurt']"
    • Use the predefined variable and add "_remove" as a suffix as output.
  • Add the workflow activity "Add/Remove devices to/from Assignment" and use the variable "GetDeviceIdsByExpressionActivity_DevicesIDs_new" as "Added Devices" expression, "GetDeviceIdsByExpressionActivity_DevicesIDs_remove" as "Removed Devices" expression and "GetAssignmentIdByNameActivity_GroupID" as "Group ID".
  • Save, Check in and release the workflow.

Update_Frankfurt_WF.png

Create an Engine Activation

  • In Administration -> Services & Processes -> Engine Activations select "Add Engine Activation".
  • Use "Update Frankfurt" as name and provide a description.
  • Add a "Activated Engine" and select "Start Workflow" as activated engine.
  • Select the newly created workflow "Update Frankfurt Assignments" as Workflow ID.
  • Add a schedule which runs nightly once a day.
  • Finish and Save.

Engine_Act_Frankfurt.png

Change the location of devices to and from Frankfurt (needs to be created before) to test the example by activation the engine activation.

  • Was this article helpful?