skipcheck

TM1 client · Docs · Processes and chores

ProcessService

using Skipcheck.Tm1.Client.Services;

Used in the walkthrough Run a process and read its result.

Processes (TurboIntegrator): /Processes, compiling and running them, and their error logs.

Parameters go as a map of name to value, in order; a numeric parameter needs a number, not text. Running a process returns when it ends, however long that takes: give the request a timeout that fits, and know that cancelling the call doesn't stop the process on the server.

Create a process, compiling it first, since TM1 saves code that doesn't compile:

// TM1 saves code that doesn't compile, so compile the definition first
var process = ProcessPatch
    .Builder()
    .Name("Load Sales")
    .Parameters([
        ProcessParameterPatch.Builder().Name("pVersion").Value("Actual").Type(ProcessVariableType.String).Build(),
        ProcessParameterPatch.Builder().Name("pYear").Value(2026).Type(ProcessVariableType.Numeric).Build(),
    ])
    .PrologProcedure("LogOutput('INFO', 'Loading ' | pVersion | ' for ' | NumberToString(pYear));\n")
    .Build();
var errors = await tm1.Processes.CompileAsync(process).ToListAsync();
if (errors.Count > 0)
{
    throw new ArgumentException("The process doesn't compile: " + string.Join("; ", errors.Select(e => e.Message)));
}
return await tm1.Processes.CreateAsync(process);

Run it with parameters, and fail if it wrote an error log:

// Parameters by name, in order; a numeric one takes a number, not text
var parameters = new Dictionary<string, object?> { ["pVersion"] = "Forecast", ["pYear"] = 2026 };
var result = await tm1.Processes.ExecuteWithReturnAsync("Load Sales", parameters, ODataQuery.None().Expand(ProcessExecuteResult.Fields.ErrorLogFile));
// A run that ended with errors names the log it wrote
if (result.ErrorLogFile is { } log)
{
    throw new InvalidOperationException($"{result.ProcessExecuteStatusCode}: see {log.Filename}");
}
return result;

Run code without saving it as a process:

// A one-off run of code that isn't saved as a process
var cleanup = ProcessPatch.Builder().Name("Clear Sales Staging").PrologProcedure("CubeClearData('Sales Staging');\n").Build();
return await tm1.Processes.ExecuteWithReturnAsync(cleanup);

Members

ProcessService constructorA service that sends its requests through session.
ListAsyncGET Processes, streamed.
GetAsyncGET Processes('name').
CreateAsyncCreates a process; it needs a name.
UpdateAsyncChanges the properties the patch sets, such as a procedure.
DeleteAsyncDELETE Processes('name').
CompileAsyncCompiles a saved process.
CompileAsyncCompiles a process definition that needn't be saved, such as one about to be created.
ExecuteWithReturnAsyncRuns a process and says how it ended (ProcessExecuteStatusCode, and the error log's file if it wrote one.
ExecuteWithReturnAsyncRuns a process definition that needn't be saved, and says how it ended.
ExecuteAsyncRuns a process, without saying how it ended.
ExecuteAsyncRuns a process definition, without saying how it ended.
ErrorLogsAsyncGET Processes('name')/ErrorLogs, streamed.
ErrorLogContentAsyncAn error log's text.

ProcessService

constructor
ProcessService(Tm1Session session)

A service that sends its requests through session.

ListAsync

IAsyncEnumerable<Process> ListAsync(ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Processes, streamed.

TM1 REST EntitySet Processes

GetAsync

Task<Process> GetAsync(string name, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Processes('name'). TM1 (11.8) leaves most of DataSource, and UIData and VariablesUIData, out of a $select=*: select them by name, or select nothing, to get them.

TM1 REST EntitySet Processes

CreateAsync

Task<Process> CreateAsync(ProcessPatch process, CancellationToken cancellationToken = default)

POST Processes: creates a process; it needs a name. TM1 (11.8) saves code that doesn't compile: check it with CompileAsync first.

TM1 REST EntitySet Processes

UpdateAsync

Task UpdateAsync(string name, ProcessPatch patch, string? etag = null, CancellationToken cancellationToken = default)

PATCH Processes('name'): changes the properties the patch sets, such as a procedure. With etag (Process.ETag), sent as If-Match: only if the process hasn't changed since, else a Tm1PreconditionFailedException. TM1 (11.8) saves code that doesn't compile.

TM1 REST EntitySet Processes

DeleteAsync

Task DeleteAsync(string name, CancellationToken cancellationToken = default)

DELETE Processes('name').

TM1 REST EntitySet Processes

CompileAsync

IAsyncEnumerable<ProcessSyntaxError> CompileAsync(string name, CancellationToken cancellationToken = default)

tm1.Compile: compiles a saved process: the syntax errors, by procedure and line; none if it compiles. Needs schema 11.0.0.

TM1 REST Action Process/Compile

CompileAsync

IAsyncEnumerable<ProcessSyntaxError> CompileAsync(ProcessPatch definition, CancellationToken cancellationToken = default)

CompileProcess: compiles a process definition that needn't be saved, such as one about to be created. Needs schema 11.0.0.

TM1 REST ActionImport CompileProcess

ExecuteWithReturnAsync

Task<ProcessExecuteResult> ExecuteWithReturnAsync( string name, IReadOnlyDictionary<string, object?>? parameters = null, ODataQuery? query = null, CancellationToken cancellationToken = default )

tm1.ExecuteWithReturn: runs a process and says how it ended (ProcessExecuteStatusCode, and the error log's file if it wrote one: expand ErrorLogFile to see it). Needs schema 11.3.0. A ProcessError, or a runtime error, ends it Aborted, with an ErrorLogFile named tm1processerror_<time>_<process>.log. A run cancelled through its thread (ThreadService.CancelAsync) fails instead, with a Tm1ServerException (TM1UserException: Cancel, code 174).

TM1 REST Action Process/ExecuteWithReturn Navigation ProcessExecuteResult/ErrorLogFile

ExecuteWithReturnAsync

Task<ProcessExecuteResult> ExecuteWithReturnAsync( ProcessPatch definition, IReadOnlyDictionary<string, object?>? parameters = null, ODataQuery? query = null, CancellationToken cancellationToken = default )

ExecuteProcessWithReturn: runs a process definition that needn't be saved, and says how it ended. Needs schema 11.3.0.

TM1 REST ActionImport ExecuteProcessWithReturn Navigation ProcessExecuteResult/ErrorLogFile

ExecuteAsync

Task ExecuteAsync(string name, IReadOnlyDictionary<string, object?>? parameters = null, CancellationToken cancellationToken = default)

tm1.Execute: runs a process, without saying how it ended. Deprecated in TM1 schema 11.3.0: use ExecuteWithReturnAsync.

TM1 REST Action Process/Execute

ExecuteAsync

Task ExecuteAsync(ProcessPatch definition, IReadOnlyDictionary<string, object?>? parameters = null, CancellationToken cancellationToken = default)

ExecuteProcess: runs a process definition, without saying how it ended. Needs schema 11.0.0; deprecated in 11.3.0: use ExecuteWithReturnAsync.

TM1 REST ActionImport ExecuteProcess

ErrorLogsAsync

IAsyncEnumerable<ProcessErrorLog> ErrorLogsAsync(string name, ODataQuery? query = null, CancellationToken cancellationToken = default)

GET Processes('name')/ErrorLogs, streamed: the logs its failed runs wrote, keyed by their timestamps. Deprecated in TM1 schema 11.3.0, with ProcessErrorLog: a run's log is the ErrorLogFile that ExecuteWithReturnAsync returns.

TM1 REST Navigation Process/ErrorLogs

ErrorLogContentAsync

Task<string> ErrorLogContentAsync(string name, ProcessErrorLog log, CancellationToken cancellationToken = default)

GET Processes('name')/ErrorLogs('timestamp')/Content: an error log's text. TM1 keys error logs by their timestamp as a quoted string, as it lists it.

TM1 REST Navigation Process/ErrorLogs