Configure Advanced User Assignment (Agents)

The Advanced/Custom User Assignment is an optional, custom assignment mode for Agents Actions. Instead of using the default rule-based assignment, it lets the system assign actions dynamically based on custom business logicimplemented by a Configuration Engineer (CE).

Prerequisites

  • Pricefx Agents version 1.7.0 or higher.

  • Access to Administration > Logics > Groovy Library.

  • Access to Administration > System Settings > Advanced Configuration Options.

Configure Advanced User Assignment

To implement custom assignment logic, you must create the logic in a library and then register it in the system configuration.

Create Assignment Logic

  1. Go to Administration > Logics > Groovy Library.

  2. Click Add Logic.

    1. In the Add New Groovy Library Logic menu:

    2. Enter Name.

    3. Enter Label (optional).

    4. Select Valid After date.

    5. Set Status to Active.

    6. Click Add.
      info This will create a new library, such as AG_ActionAssignment_Lib.

  3. Click the newly created logic.

  4. Click Add.
    info This will define a new element within the newly created logic.

  5. Select {} in Type.

  6. Enter Element Name.
    info Function (e.g., CustomAssignmentStrategy) that contains your proper logic for user assignment.

  7. Enter Element Label (optional).

  8. Enter the logic code in Code Editor.
    info This logic can use inputs for mapping or dimension-based rules.
    Logic Example

    Groovy
    import groovy.transform.Field
    import net.pricefx.server.dto.calculation.ConfiguratorEntry
    import net.pricefx.server.dto.calculation.ContextParameter
    
    @Field String ADVANCED_ASSIGNMENT_NAME = "inputMatrixAssignment"
    @Field Map INPUT_COLUMNS = [SEGMENT    : "country",
                                ASSIGNED_TO: "AssignTo"]
    
    ConfiguratorEntry getAssignmentInputs(Map inputParam) {
        //Script actionDefinitionManager = libs.AG_Library.ActionDefinitionManager
    
        List columns = (INPUT_COLUMNS as Map).values() as List
        ConfiguratorEntry advancedAssignmentEntry = api.createConfiguratorEntry()
    
        ContextParameter advancedAssignmentParameter = api.inputBuilderFactory()
                .createInputMatrix(ADVANCED_ASSIGNMENT_NAME)
                .setLabel("Custom assignment")
                .setColumns(columns)
                .setReadOnly(true)
                .setEnableAdvancedFilter(false)
                .setEnableClientFilter(false)
                .setHideAddButton(true)
                .buildContextParameter()
    
        List rows = []
        List segments = ["Germany", "France"]
        List assigns = ["tram1", "vinh"]
        segments.eachWithIndex { String segment, int index ->
            Map row = [(INPUT_COLUMNS.SEGMENT) : segments.getAt(index),
                       (INPUT_COLUMNS.ASSIGNED_TO): assigns.getAt(index)]
            rows.add(row)
        }
    
        Map fallbackRow = [(INPUT_COLUMNS.SEGMENT) : "*",
                       (INPUT_COLUMNS.ASSIGNED_TO): "tram1"]
            rows.add(fallbackRow)
      
        advancedAssignmentParameter.setValue(rows)
    
        advancedAssignmentEntry.createParameter(advancedAssignmentParameter)
    
        return advancedAssignmentEntry
    }
    
    List<Map> getAssignments(Map actionDefinition, List dimensions) {
        //Script actionDefinitionManager = libs.AG_Library.ActionDefinitionManager
        Map actionData = actionDefinition.data
        List assignments = actionData[ADVANCED_ASSIGNMENT_NAME] ?: []
    
        return assignments.collect { Map assignment ->
            Map data = [:]
            String assignTo = getAssignmentAssignTo(assignment)
            data.assignTo = assignTo
            String dimension = "country"
            data[dimension] = getCustomerGroupValue(assignment)
    
            return data
        }
    }
    
    protected String getAssignmentAssignTo(Map assignment) {
        api.logInfo("--DEBUG:getAdvancedAssignTo-assignment", assignment)
        return assignment.getAt(INPUT_COLUMNS.ASSIGNED_TO)
    }
    
    protected def getCustomerGroupValue(Map assignment) {
        return assignment[INPUT_COLUMNS.SEGMENT]
    }
    
  9. Click Save and Close.

Register Custom Assignment Type

  1. Go to Administration > System Settings > Advanced Configuration Options.

  2. Click Add.

  3. In the Add Option menu:

    1. Enter the pfxAcc_AG_Assignment_Types_Extension_Config into Name.

    2. Set the Type to TEXT.

    3. In the Value field, provide a JSON object defining your custom option.
      Configuration Example

    4. {
        "Custom": {
          "label": "Custom",
          "description": "Assigns by dimension-based my custom rules without fallback to default user",
          "enginePath": "libs.AG_ActionAssignment_Lib.CustomAssignmentStrategy"
        }
      }
      
  4. Click Add.

Expected Result

When the Agent runs, it will bypass the Standard rule-based assignment and execute the Groovy function defined in the enginePath. The Action Assignment will be performed according to your custom dynamic logic.

Agent_Action_Definition_Step_Add_Action_Menu_Custom.png

Standard is the default behavior. It uses the current configurator logic to assign actions based on dimension-based rules with a fallback to a specific user.

See Also