If the set of available powerFLC cmdlets does not cover all needs you can use the Fusion Lifecycle REST API to extend your  Workflow jobs.


Using the REST API

After successfully connecting to Fusion Lifecycle using Connect-FLC you can use Invoke-RestMethod to communicate with Fusion Lifecycle by using the information provided by the $flcConnection variable.

This variable also handles refreshing the access token automatically. This token is required for all our next requests to the Fusion Lifecycle REST APIs.


This example gets a maximum of 50 Workspaces from the Fusion Lifecycle Workspace v3 API and then gets the possible workflow states for each workspace.

$workspaces = Invoke-RestMethod -Uri "$($flcConnection.Url)api/v3/workspaces?limit=50" -Method Get -Headers @{
"Accept" = "application/json"
"Authorization" = $flcConnection.AuthenticationToken
"X-user-id" = $flcConnection.UserId
"X-Tenant" = $flcConnection.Tenant
}

The result from the workspaces Endpoint can directly be consumed in the PowerShell script afterwards.

Following example prints all the available Workspace titles and their links to the console:

$workspaces.items | Format-Table title,link
<#
title                                   link
-----                                   ----
BOM_Support                             /api/v3/workspaces/82
Products                                /api/v3/workspaces/47
Tasks                                   /api/v3/workspaces/2
Items and BOMs                          /api/v3/workspaces/57
Documents                               /api/v3/workspaces/71
Design Review                           /api/v3/workspaces/69
Problem Report                          /api/v3/workspaces/54
Change Request                          /api/v3/workspaces/26
Change Orders                           /api/v3/workspaces/9
Document Change Order                   /api/v3/workspaces/70
Deviation and Waiver Requests           /api/v3/workspaces/53
Suppliers                               /api/v3/workspaces/14
Audits                                  /api/v3/workspaces/22
SQBR Supplier Quarterly Business Review /api/v3/workspaces/73
Customers                               /api/v3/workspaces/5
Non Conformances                        /api/v3/workspaces/19
...
#>


This example gets the workflow states for all returned workspaces:

foreach ($Workspace in $workspaces.Items) {
    $workflowStates = Invoke-RestMethod -Uri "$($flcConnection.Url.AbsoluteUri)$($Workspace.Link)/workflows/1/states" -Method Get -Headers @{
        "Accept"        = "application/json"
        "Authorization" = $flcConnection.AuthenticationToken
        "X-user-id"     = $flcConnection.UserId
        "X-Tenant"      = $flcConnection.Tenant
    }        
    if ($workflowStates) {
        Write-Host "Workflow '$($Workspace.Title)' has following states: $($workflowStates.States.Name -join ', ')"
    } else {
        Write-Host "Workflow '$($Workspace.Title)' has no states"
    }
}

<# The output look like this:
Workflow 'Items and BOMs' has no states
Workflow 'Documents' has no states
Workflow 'Design Review' has following states: Preparing, In-Progress, Closed
Workflow 'Problem Report' has following states: Create, Initial Review, ECR In Progress, Closed, Technical Review, CAPA In Progress
Workflow 'Change Request' has following states: Engineering Evaluation, CCB Review, Create, Complete, Fast Track, Cancel
...
#>


Some more Resource Endpoints can be found here in the REST API v3 Reference (or in the REST API v1 Reference).


See Also

How to create a custom workflow using the FLC cmdlets (coolOrange knowledge base)

powerFLC (coolOrange wiki)

Fusion Lifecycle documentation (Autodesk)