Add-BomWindowEntity
Creates and adds a new entity to the BOM Tab.
Syntax
1 | Add-BomWindowEntity [[-Type] <BomWindowEntityType>] [[-Properties] <Object>] [[-Parent] <PSObject>] [<CommonParameters>] |
Parameters
Type |
Name |
Description |
Optional |
---|---|---|---|
Type |
Specifies whether adding a new BomRow or an |
no |
|
PsObject |
Parent |
For |
yes (not when Type is ‘BomRow’) |
Hashtable / PsObject |
Properties |
The properties for the entity being created |
yes |
Return type
BomRow / Item ← on success
empty ← on failure. Exception/ErrorMessage can be accessed using $Error.
Remarks
The Cmdlet’s purpose is to add a new BomRow or Material (Item) to the BOM Window.
The entity’s default State is “Unknown”.
BomRow:
In general two categories of Properties can be provided for all newly created 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.
@{'Number'= ...}
). They are available in the BOM-Tab as well.
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.
Material:
It is possible to create the new Material directly with Properties.
The name for the new Item can be specified as
@{'Number'= ...}
.Other custom properties can be specified like
@{'Description'= … ; '_Title(Item,CO)'= …}
.
A newly added Material has no associated BomRow.
Examples
Adding a new material in the BOM Window:
1 | $newMaterial = Add-BomWindowEntity -Type Material -Properties @{'Number'='100001'} |
Adding a new BomRow to a BOM in the BOM Window:
1 | $newBomRow = Add-BomWindowEntity -Type BomRow -Parent $bom -Properties @{'Bom_Number'='PAD LOCK';'Bom_Quantity'= 23.4;'Bom_PositionNumber'=6} |
Adding BomRows with information from the ERP as BOM properties:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | $erpBomRow = Get-ERPObject -EntitySet "BomItems" -Keys @{ "ChildNumber"="IWillBeDeleted";"ParentNumber"="CheckBoms";"Position"=1 } $erpBomProperties = @{} foreach ($property in $erpBomRow._Keys.PsObject.Properties) { #Adding _Keys with "Bom_" prefix to pass them as Bom properties $erpBomProperties["Bom_"+$property.Name] = $property.Value } foreach ($property in $erpBomRow._Properties.PsObject.Properties) { #Adding _Properties with "Bom_" prefix to pass them as Bom properties $erpBomProperties["Bom_"+$property.Name] = $property.Value } Add-BomWindowEntity -Type BomRow -Parent $bom -Properties $erpBomProperties <# Bom_Number : Bom_PositionNumber : 1 Bom_Quantity : 1 Bom_ChildNumber : IWillBeDeleted Bom_ParentNumber : CheckBoms _Status : Unknown _StatusDetails : #> |
Adding new BomRows that exists in the ERP BOM but not in the Vault BOM and mark them with Status ‘Remove’:
1 2 3 4 5 6 7 8 9 10 11 12 | functionCheck-Boms($boms) { foreach($vaultBom in $boms) { $erpBom = Get-ERPObject -EntitySet "Boms" -Keys @{ "ParentNumber"= $vaultBom.Bom_Number } -Expand "Children" foreach($erpBomRow in $erpBom.Children) { $vaultBomRow = $vaultBom.Children | Where-Object { $_.Bom_Number -eq $erpBomRow.ChildNumber -and $_.Bom_PositionNumber -eq $erpBomRow.Position } | select -First 1 if($vaultBomRow -eq $null) { $erpBomRow_to_remove = Add-BomWindowEntity -Type BomRow -Parent $vaultBom $erpBomRow_to_remove | Update-BomWindowEntity -Status 'Remove' -StatusDetails 'Row will be deleted in ERP.' } } } } |