powergate:code_reference:commandlets:show-bomwindow:commandlets:update-bomwindowentity

Update-BomWindowEntity

Updates an entity in the BOM Window.

Update-BomWindowEntity [[-InputObject] <PSObject>] [[-Status] <Status>] [[-Tooltip] <string>] [[-Properties] <Object>] [<CommonParameters>]

Type Name Description Optional
BOM / BomRow / Item InputObject An entity displayed in the BOM Window. The argument accepts pipeline inputno
Status Status The new status of the entityyes
String Tooltip The new tooltip message of the entityyes
Hashtable / PsObject Properties The new properties for the entity being updatedyes

void

The commandlet can be used to update BOM, BomRow and Item Properties, States and Tooltips in the BOM Window.

Status and Tooltip:
When updating the Status the according Tooltip gets reset when no custom Tooltip is specified.
Additionally, when updating the Status of an entity, the progress in the BOM Window will be automatically incremented for that entity.

Properties:
It is possible to pass new Properties, update existing ones or remove them from the entity as required.

BomRow:
In general two categories of Properties can be provided for BomRows:

  • BOM properties are properties prefixed with 'Bom_' (e.g. @{'Bom_Number'= …, 'Bom_Quantity'= …, 'Bom_PositionNumber'= …}).
    They are displayed only in the BOM-Tab without the prefix.
  • Entity properties are all other properties (e.g. @{'_Name'= …}).
    They are displayed in both the BOM-Tab and the Items-Tab.

Custom BOM properties (e.g. @{'Bom_Unit'= … ;'Bom_ItemQuantity'= …}) and Entity properties (e.g. @{'Description'= … ; 'SomEntityProperty'= …}) can be passed and later displayed as columns in the BOM Window.
They are replacing the current set of BomRow properties or the once of the associated Item.

Material:

  • The standard property @{'_Name'= …} can be passed in order to update the item number if required.
  • Other properties are replacing the current set of custom properties for instance @{'Description'= … ; '_Title(Item,CO)'= …}.

Updating the Status and Tooltip of a BOM :

$bom | Update-BomWindowEntity -Status 'Identical' -Tooltip 'WORKED'

Setting new properties for an Item:

$item | Update-BomWindowEntity -Properties @{"SomeProperty" = "true";"SomeOtherProperty"=6.66}

Adding properties to a BomRow:

$bomRow | Add-Member -MemberType NoteProperty -Name "Bom_Some_new_property" -Value "Plup"
$bomRow | Add-Member -MemberType NoteProperty -Name "Some_other_new_property" -Value $null
$bomRow | Update-BomWindowEntity -Properties $bomRow

Updating the Item's Status and Tooltip, depending on the existence and equality to the material in ERP:

function Check-Items($items) {
    foreach($item in $items) {
        $erpMaterial = Get-ERPObject -EntitySet 'Materials' -Keys @{'Number'=$item._PartNumber} -Expand "Descriptions"
        if($erpMaterial -eq $null) {
            $item | Update-BomWindowEntity -Status 'New'
        }else{
            if( $item._Description -cne ($erpMaterial.Descriptions | select -First 1).Description) {
                $item | Update-BomWindowEntity -Status 'Different' -ToolTip "Description is Different!"
            }else{
                $item | Update-BomWindowEntity -Status 'Identical'
            }
        }
    }
}

Updating a standard BOM property on a BomRow:

$bomRow | Update-BomWindowEntity -Properties @{"Bom_PositionNumber" = 4}