When syncing the Vault BOM information to Fusion Lifecycle using the Transfer File BOMs workflow, all the BOM line items that were manually added to the item are getting removed.

Using the powerFLC cmdlets it is possible to find these line items for re-uploading them together with all the bomRows coming from Vault. 


Required Fusion Lifecycle configuration

In order to allow differentiating between manually added BOM line items and bomRows that where added from powerFLC, a new Custom BOM Field is required in the Bill of materials tab.

Navigate to the Workspace Manager, find your Workspace and the BOM Tab configuration. We recommend creating a new BOM Field of type Picklist called e.g. "Source" with the defined values "Fusion Lifecycle" and "Vault".

In order to not force Fusion Lifecycle users to specify the correct Field value when adding BOM list items, we can specify the Default Value to be "Fusion Lifecycle" for the previously created BOM Field.

The custom BOM Field must be added to at least one View.


Workflow to keep manually added BOM line items

With this configuration it is possible to retrieve manually added BOM line items for items in Fusion Lifecycle and only override the bomRows that are coming from Vault.

In order to keep the following examples as simple as possible, we assume that the according Fusion Lifecycle items where already created.

Find examples for creating or updating them automatically in Customize your own workflow.


Find header item

In the following example we connect to Fusion Lifecycle and search for the respective item of a file in Vault using its "Part Number" property.

The header item is searched in the 'Items and BOMs' workspace using the Field "itemID" and the "_PartNumber" property from the powerVault File object.

When working with revision-controlled workspaces the "Part Number" in Vault and the "itemID" Field in Fusion Lifecycle must stay the same for all item revisions in Fusion Lifecycle in order to find the according item.

Import-Module powerFLC
$connected = Connect-FLC -Tenant 'your_tenant_name' -ClientId 'your_client_id' -ClientSecret 'your_client_secret' -UserId 'your_email@example.com'

Import-Module powerVault
Open-VaultConnection
$file = Get-VaultFile -Properties @{"File Name"="Pad Lock.iam"}

$item = (Get-FLCItems -Workspace 'Items and BOMs' -Filter ('ITEM_DETAILS:ITEMID="{0}"' -f $file._PartNumber))[0]


Find manually added bomRows

In order to get the current BOM information for the Fusion Lifecycle item we can use the Get-FLCBOM cmdlet. 

Following example filters for manually added BOM line items using the previously described "Source" BOM Field:

$bomRows = $item | Get-FLCBOM
$manuallyAddedBomRows = $bomRows | Where-Object {$_.Bom_Source -eq "Fusion Lifecycle"}


Get BOM information from Vault

Next we can retrieve the Vault file BOM information and find the respective Fusion Lifecycle items for all the components similar as we did for the header item.

As described before we assume that the according items already exist in Fusion Lifecycle.

In contrast to the example in Customize your own workflow we retrieve all the according items in a single Get-FLCItems step by combining them with OR conditions.

Note that we have to mark all this items to be retrieved from Vault by using the "Bom_Source" property:

$vaultBomRows = @()

$fileBom = Get-VaultFileBom -File $file._FullPath
$childItems = Get-FLCItems -Workspace $item.Workspace -Filter (($fileBom | foreach-object {'ITEM_DETAILS:ITEMID="{0}"' -f $_.'Bom_Part Number'}) -join ' OR ') 
foreach ($fileBomRow in $fileBom) {
    $childItem = $childItems | where-object { $_.itemID -eq $fileBomRow.'Bom_Part Number' }[0]
    $vaultBomRows += @{
        'Bom_PositionNumber'= $fileBomRow.Bom_PositionNumber
        'Workspace' = $childItem.Workspace
        'Id'= $childItem.Id
        'Bom_Quantity'= $fileBomRow.Bom_Quantity
        'Bom_Source' = 'Vault'
    }
}


Update BOM information in Fusion Lifecycle

Now we can simply update the BOM information of the Fusion Lifecycle item using Update-FLCBOM cmdlet, by passing the Vault File BOM data together with the previously retrieved BOM line items that where added manually in Fusion Lifecycle:

$item | Update-FLCBOM -Rows ($vaultBomRows + $manuallyAddedBomRows)

Find more information about how to customize your own workflow directly on the Job Processor using a custom powerJobs Processor job and the previous PowerShell script.


See Also

Create a custom workflow using the powerFLC cmdlets (coolOrange knowledge base) 

Transfer File BOMs workflow (coolOrange wiki)

powerFLC cmdlets (coolOrange wiki)

powerVault File object (coolOrange wiki)

Create a powerJobs Processor Job (coolOrange wiki)

Custom BOM Fields (Fusion Lifecycle help page)