workflow platform

ATF: Step Configuration to Find Assigned To Value

In many workflows, someone is often assigned to carry out a task or request. In this article, we will discuss setting up a custom step configuration that will allow a user to obtain the Assigned To value of a given record. The user will input a table name and record ID. The record will be queried when the step is run, and the Assigned To value will be available for future test steps.

Using this step can be beneficial for users looking to complete workflows as the assignee without having to hardcode sys_user values to impersonate, as this can change over time and lead to a false negative.

All data pertaining to the user is also available for use should you wish to use the assignee’s email, manager name, or other user data in future test steps.

Input/Output Variables

This step configuration will require both input and output variables. We need to know the record which holds the Assigned To value and what table we should query to find the record.

This allows us to get the assigned to value from any record where the key is assigned_to


Both inputs are required for this step configuration to perform as intended.

The output variable will be a reference to the sys_user table.


Once the step has been run, the returned user data will be ready to be used in future tests.


Step Execution Script

(function executeStep(inputs, outputs, stepResult) {
  // User input record
    var record = inputs.u_record;
  // User input table
    var recordTable = new GlideRecord(inputs.u_record_table);

  // Query to obtain the record data

  // If the returned record is valid
    if (recordTable.isValid()) {
	// If the the assigned_to value is empty
        if (recordTable.assigned_to.nil()) {
	   // Fail the step and display the appropriate failure message
            stepResult.setOutputMessage('The assigned to value is empty. Please check the record.');
        } else {
	   // If the value is not empty, assign the user record as an output and display the success message
            outputs.u_assigned_to_user = recordTable.assigned_to;
            stepResult.setOutputMessage('Successfully found the requested record. The user assigned to the record is ' + recordTable.assigned_to.getDisplayValue());
    } else {
	// If the record is invalid, display the appropriate message and fail the step
        stepResult.setOutputMessage('No record found with ID: ' + record + ' in the table: ' + inputs.u_record_table);
})(inputs, outputs, stepResult);