Main Content

padv.util.setUserTaskResult

Set results for user task

    Description

    padv.util.setUserTaskResult(TaskKey=taskkey,Results=results) sets the task results for the user task iteration specified by TaskKey.

    example

    padv.util.setUserTaskResult(___,Name=Value) sets the task results with options specified using one or more name-value arguments.

    Note

    For R2025a, this functionality will be available in a future release of the support package.

    example

    Examples

    collapse all

    If your user task depends on incomplete predecessor tasks, you can force the user task results by using the padv.util.setUserTaskResult function.

    Open a project. For this example, you can open the Process Advisor example project.

    processAdvisorExampleStart

    Inside the processmodel.m file, suppose you define this process model.

    function processmodel(pm)
        % Defines the project's processmodel
    
        arguments
            pm padv.ProcessModel
        end
    
        taskA = pm.addTask("TaskA",TaskType=padv.TaskType.User);
        taskB = pm.addTask("TaskB",Action=@MyTaskAction);
        taskC = pm.addTask("TaskC",TaskType=padv.TaskType.User);
        taskC.dependsOn(taskB); % unable to complete task C until task B complete
        taskB.runsAfter(taskA); % put task A before task B in the Tasks column
    
    end
    
    function taskResult = MyTaskAction(~)
        taskResult = padv.TaskResult;
    end
    In this process model, TaskC depends on TaskB, meaning that you normally cannot complete TaskC until TaskB is complete. However, you can force the task results for TaskC by using the padv.util.setUserTaskResult function.

    Find the available task keys by generating a list of keys for the task iterations in the process. In the MATLAB® Command window, enter:

    taskKeys = generateProcessTasks()
    taskKeys = 
    
      1×3 string array
    
        "TaskA|project|ProcessAdvisorExample|ProcessA…"    "TaskB|project|ProcessAdvisorExample|ProcessA…"    "TaskC|project|ProcessAdvisorExample|ProcessA…"
    
    In this example, TaskC is the user task for which we want to force the task results.

    Save the task key for TaskC into a variable.

    userTaskKey = taskKeys(3)
    userTaskKey = 
    
        "TaskC|project|ProcessAdvisorExample|ProcessAdvisorExample.prj"

    Create a task result by using a padv.TaskResult object. You can use the properties of the object to specify the task status, details, and other task result information.

    userTaskResult = padv.TaskResult;

    Force the task results for user task TaskC by using the padv.util.setUserTaskResult function with Force set to true.

    padv.util.setUserTaskResult(TaskKey=userTaskKey, ...
    Results=userTaskResult, ...
    Force=true)
    If you Refresh Tasks in Process Advisor, the user task TaskC appears as complete .

    Input Arguments

    collapse all

    Unique identifier for task iteration, specified as a string scalar. The task key that you specify must be for a user task. User tasks have a TaskType property set to padv.TaskType.User.

    To get the available task iteration identifiers for a process, you can use the generateProcessTasks function.

    Example: "TaskA|project|ProcessAdvisorExample|ProcessAdvisorExample.prj"

    Data Types: string

    Task results, specified as a padv.TaskResult object.

    You can use the properties of the object to specify the task status, details, and other task result information.

    Example: padv.TaskResult

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: padv.util.setUserTaskResult(TaskKey=userTaskKey,Results=userTaskResult,Force=true)

    Name of process, specified as a string scalar.

    Example: "CIPipeline"

    Example: "ProcessA"

    Data Types: string

    Allow setting user task results even if predecessor tasks are incomplete, specified as a numeric or logical 0 (false) or 1 (true).

    If you specified that your user task depends on other tasks, those other tasks are considered predecessor tasks. By default, you cannot mark a user task as complete until the predecessor tasks are complete, but setting Force to true overrides this restriction.

    Data Types: logical

    Alternative Functionality

    App

    In the Process Advisor app, you can manage user task statuses and outputs by using the Edit Task State dialog box. For more information, see Create User Tasks.