ProcessInstances.GetModelDataByWorkflowAsync
Description
Retrieves the Workflow Data for a specified workflow instance within a process instance from the connected AI Command Center.
You can optionally specify a set of Workflow Data field keys to retrieve only selected data.
Workflow Data is the current display name for Model Data. The SDK method and model names retain ModelData for backward compatibility. See Workflow Data.
Signature [C#]
Task<string> GetModelDataByWorkflowAsync(string processInstanceId, string workflowInstanceId, IEnumerable<string> fields = null);
Parameters
Input
| Property | Description |
|---|---|
processInstanceId | The ID of the parent process instance. |
workflowInstanceId | The ID of the workflow instance within the process. |
fields | Optional. A collection of Workflow Data field keys to filter the returned data. |
Returns
| Type | Description |
|---|---|
Task<string> | A task returning a JSON string containing the requested Workflow Data. |
Remarks
- The
processInstanceIdidentifies the parent process. - The
workflowInstanceIdidentifies the specific workflow instance. - If
fieldsis null, all Workflow Data is returned. - If
fieldscontains values, only matching Workflow Data variables are returned. - The operation executes asynchronously.
Use this API to retrieve runtime Workflow Data for a specific workflow instance.
Example
C#
public async Task GetModelDataByWorkflow()
{
IControlRoomContext context = LoginControlRoom();
try
{
string processInstanceId = "e42a93f5d53245d788909fd655b41cfe";
string workflowInstanceId = "58bfe04d347540188dfdb55f2e16f5ec";
var fields = new[]
{
"InvoiceId",
"Amount"
};
string modelData = await context.ProcessInstances.GetModelDataByWorkflowAsync(processInstanceId, workflowInstanceId, fields);
System.Console.WriteLine("Workflow Data: " + modelData);
}
finally
{
context.Close();
}
}
Connection helper
public IControlRoomContext LoginControlRoom()
{
string RequiredSetting(string name) => Environment.GetEnvironmentVariable(name) ?? throw new InvalidOperationException($"Set {name} before running this example.");
string serverUrl = RequiredSetting("INTELLIBUDDIES_SERVER_URL");
string userName = RequiredSetting("INTELLIBUDDIES_USERNAME");
string password = RequiredSetting("INTELLIBUDDIES_PASSWORD");
string connectionString = $"ServerUrl={serverUrl};UserName={userName};Password={password}";
IControlRoomContext context = new ControlRoomContext(connectionString);
context.Open();
return context;
}
See Get started for namespaces, configuration, and context cleanup, and SDK usage for error handling.