API to access list of Process Steps

Occasional Contributor

API to access list of Process Steps

I'm currently using the Anaplan Integration API to upload files and run processes containing imports. This all works great.

Currently if I want to run a process I need to be careful to upload all files associated with any imports it runs beforehand. What I'd like to do is to query the process I want to run and discover what import actions it runs. I can then query those to work out what files I should upload first.

I see I can get the current step of a running process, but I can't see how I can get a list of all steps that a process has. Is this possible?

Occasional Contributor

Re: API to access list of Process Steps

In case it's useful, I figured out that once i got a process id for a given process I can query /processes/ProcessId to get the actions. I then query the list of imports to find the corresponding import details for any action that is an import, then I query files to get the info about the datasource:


var anaplanFiles = await client.GetJsonObjectAsync<FilesResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/files");
Console.Write($"Getting list of processes.{new string(' ', Console.WindowWidth)}".Substring(0, Console.WindowWidth - 1) + "\r");
// Get details of processes
List<Process> anaplanProcesses =
    (await client.GetJsonObjectAsync<ProcessesResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/processes")).Processes;

var processIdsByName = anaplanProcesses.ToDictionary(p => p.Name, p => p.Id);

Console.Write($"Getting list of actions.{new string(' ', Console.WindowWidth)}".Substring(0, Console.WindowWidth - 1) + "\r");
var anaplanActions = (await client.GetJsonObjectAsync<ActionsResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/actions")).Actions;

Console.Write($"Getting list of actions for each process.{new string(' ', Console.WindowWidth)}".Substring(0, Console.WindowWidth - 1) + "\r");
var processesActionsToRunTasks = ProcessesToRun
    .Select(async p => (await client.GetJsonObjectAsync<ProcessResponse>($"https://api.anaplan.com/2/0/workspaces/{WorkspaceId}/models/{ModelId}/processes/{processIdsByName[p]}")).ProcessMetadata.Actions).ToArray();

var processesActionsToRun = processesActionsToRunTasks.SelectMany(t => t.Result).Where(a => !string.IsNullOrEmpty(a.ImportDataSourceId));

var usedFiles = processesActionsToRun.Select(a => anaplanFiles.Files.Single(f => f.Id == a.ImportDataSourceId)).ToArray();