Skip to main content

Create Code-Based Sets

Create code-based Sets using custom C# code in Workflow Studio when SQL queries cannot meet your requirements. Code-based Sets use a Set Runtime class that implements the EmpowerID API to return collections of people or other resource types based on custom logic.

Prerequisites

Before creating code-based Sets, ensure you have:

  • Access to Workflow Studio with permissions to create class libraries
  • Access to Visual Studio for building .NET Framework projects
  • Access to publish Workflow Studio items in EmpowerID
  • The Set Compiler Job is enabled on at least one EmpowerID Server with the Worker Role service

Procedure

Phase 1: Create the Set Runtime Class

  1. Log into Workflow Studio.

  2. In Solution Explorer, select the Workspace node.

  3. Right-click a folder and select New Extension or Library > Class Library (.NET Framework). New Class Library

  4. In the Properties tab (right of the C# Editor), click the Supports button (). Properties Tab

  5. In the Supports dialog, select SetRuntime and click OK. Select SetRuntime

  6. In the toolbar above the C# Editor, click Save.

  7. Enter a descriptive name for the class (e.g., HelpDeskTechniciansSetRuntime) and click Save. Save Class File

  8. In the C# Editor, implement the ISetRuntime interface:

    • Set the base class to ISetRuntime
    • Implement the GetResults() method using the EmpowerID API

    Example implementation that returns all people with the title "Helpdesk Technician":

      public class HelpDeskTechniciansSetRuntime : ISetRuntime
    {
    public E.TList<SetCompilation> GetResults()
    {
    int totalCount = -1;
    E.TList<Person> people = Person.Find(
    "Title = Helpdesk Technician", 0, int.MaxValue, out totalCount);

    E.TList<SetCompilation> results = new E.TList<SetCompilation>();

    foreach (Person p in people)
    {
    results.Add(new SetCompilation()
    {
    SystemIdentifier = p.PersonGUID.ToString(),
    DisplayName = p.FriendlyName
    });
    }

    return results;
    }
    }
  9. Click Save and close the .cs file.

Phase 2: Build and Publish the Set Runtime

  1. In Workflow Studio, locate the class library in the source control tree.

  2. Double-click the class library to open it in Visual Studio.

    Note: The first time you do this, select Visual Studio as the default application. Open in Visual Studio

  3. In Visual Studio, build the solution (Build > Build Solution or Ctrl+Shift+B).

  4. After a successful build, verify the .pub file was generated in the WFS > _PublishedItems folder on your local file system. Published Items

  5. Log into the EmpowerID web application as a user with permissions to publish Workflow Studio items.

  6. Navigate to the publishing workflow by entering this URL in your browser:

    https://<YourEmpowerIDServer>/UI/#w/PublishWorkflowStudioItem
    Publish Workflow

  7. Click Choose File, browse to the _PublishedItems folder, and select the .pub file you generated.

  8. Click Submit. Submit PUB File

Phase 3: Create a Query-Based Collection and Associate the Set

  1. In the EmpowerID web application, navigate to Role Management > Query-Based Collections (SetGroup).
  2. Select the Actions tab.
  3. Click Create a Query-Based Collection (SetGroup). Create Query-Based Collection
  4. In the Create Query-Based Collection form, configure the collection:
    • Name: Enter the internal name for the collection
    • Display Name: Enter the user-friendly name
    • Description: Enter a description of the collection's purpose
    • Is a collection of person objects: Select if the Set returns person objects
    • Location: Select a location or use the default SetGroup Form
  5. Click Submit.
  6. Click OK to close the Operation Execution Summary. Submit QBC
  7. In the Select Queries lookup dialog that appears automatically:
    • Search for the Set Runtime you published by name
    • Select the checkbox for your Set Runtime
    • Click Submit to associate it with the Query-Based Collection
  8. Click OK to close the final Operation Execution Summary.

Verify the Results

After creating and publishing the code-based Set:

  1. Navigate to Role Management > Query-Based Collections (SetGroup) and select the Queries tab.
  2. Search for your Set Runtime by name to verify it appears in the list.
  3. Click the Set Runtime name to open its details and confirm the configuration is correct.
  4. Navigate to the Query-Based Collections tab and search for the collection you created.
  5. Click the collection name to open its details and verify the Set Runtime is associated with it.
  6. (Optional) Wait for the Set Compiler Job to run and verify that members appear in the Set based on your code logic.