Transfer-Boms
This function is executed when clicking the “Transfer” button within the BOM Tab.
All the BOMs from the BOM Window can be transferred to ERP.
Syntax
Transfer-Boms [-Boms] <Bom[]>>
Parameters
Type |
Name |
Description |
input/output |
Mandatory |
Default value |
---|---|---|---|---|---|
Bom [] |
Boms |
The BOMs which should be transfered |
input |
yes |
Return type
void
Remarks
Each unique BOM shown in the BOM Window with another Status then Unknown is passed to this function.
It’s recommended to update the Status of all the BOMs and their rows with the Update-BomWindowEntity cmdlet.
When an exception is thrown within this function, the BOM Window shows the Exception message of the terminated Transfer operation.
The Status of all the BOMs and their Children that where not updated, gets automatically changed to Unknown.
Examples
Creating all the Item BOMs with Status “New” in ERP. When adding succeeds the Status and StatusDetails gets updated to “Identical” otherwise to “Error”:
function Transfer-Boms($boms) {
foreach($vaultBom in $boms) {
if($bom._Status -eq 'New'){
$result = Add-ERPObject -EntitySet 'Boms' -Properties @{
'ParentNumber'= $bom._PartNumber
'Children' = @( $bom.Children | foreach-object {
@{
'ParentNumber' = $parentNumber
'ChildNumber' = $_.Bom_Number
'Position' = [int]($_.Bom_PositionNumber)
'Quantity' = $_.Bom_Quantity
}})
}
if($result){
$bom | Update-BomWindowEntity -Status 'Identical' -StatusDetails 'Successfully transfered Bom'
} else {
$bom | Update-BomWindowEntity -Status 'Error' -StatusDetails 'Error occured when transfering Bom'
}
}
}
}
Updating all BomRows with the Status “Different” in ERP and setting Status and StatusDetails on the according row:
function Transfer-Boms($boms) {
foreach($vaultBom in $boms) {
foreach($bomRow in $bom.Children){
if($bomRow._Status -eq 'Different'){
if((Update-ERPObject -EntitySet 'BomItems' -Keys $bomItem._Keys -Properties $bomItem._Properties)){
$bomRow | Update-BomWindowEntity -Status 'Identical' -StatusDetails 'Successfully updated BomRow'
} else {
$bomRow | Update-BomWindowEntity -Status 'Error' -StatusDetails 'Error occured when updating BomRow'
}
}
}
}
}