# 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 ```powershell Transfer-Boms [-Boms] > ``` ## 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 []() then *Unknown* is passed to this function. It's recommended to update the []() of all the BOMs and their rows with the []() cmdlet.\ Only in case of [connection problems]() with [ERP cmdlets]() the status of the according BOMs and rows is automatically set to *Error*. When an exception is thrown within this function, the BOM Window [shows the Exception]() message of the terminated Transfer operation.\ The []() of all the [BOMs]() and their *Children* that where not updated, gets automatically changed to *Unknown*. ## Examples **Creating all the Vault Item BOMs with Status "New" in ERP: Upon successful deep-creation they are marked as "Identical" whereby BOMs that should not be transferred are skipped:** ```powershell function Transfer-Boms($boms) { foreach($vaultBom in $boms) { if($vaultBom._Status -eq 'Identical' -or $vaultBom._Status -eq 'Error'){ $vaultBom | Update-BomWindowEntity -Status $vaultBom._Status -StatusDetails $vaultBom._StatusDetails } elseif($vaultBom._Status -eq 'New'){ $result = Add-ERPObject -EntitySet 'Boms' -Properties @{ 'ParentNumber'= $vaultBom._PartNumber 'Children' = @( $vaultBom.Children | foreach-object { @{ 'ParentNumber' = $vaultBom._PartNumber 'ChildNumber' = $_.Bom_Number 'Position' = [int]($_.Bom_PositionNumber) 'Quantity' = $_.Bom_Quantity }}) } if($result){ $bom | Update-BomWindowEntity -Status 'Identical' -StatusDetails 'BOM created in ERP' } } } } ``` *Note:* In case of connection problems during the *Add-ERPObject* cmdlet, the status of the currently iterated `$vaultBom` object is automatically set to *'Error'*.\ Further exception details can be retrieved via automatic variables like `$?` and `$Error[0]`. **Updating all BomRows with Status "Different" in ERP: setting Status and StatusDetails on the according row:** ```powershell function Transfer-Boms($boms) { foreach($vaultBom in $boms) { foreach($vaultBomRow in $vaultBom.Children){ if($vaultBomRow._Status -eq 'Different'){ $erpBomRow = Update-ERPObject -EntitySet 'BomItems' -Keys $vaultBomRow._Keys -Properties @{'Quantity'=$vaultBomRow.Bom_Quantity} if($erpBomRow){ $vaultBomRow | Update-BomWindowEntity -Status 'Identical' -StatusDetails 'BomRow updated in ERP' } } } } } ``` *Note:* In case of connection problems during the *Update-ERPObject* cmdlet, the status of the currently iterated `$vaultBomRow` object is automatically set to *'Error'*.\ Further exception details can be retrieved via automatic variables like `$?` and `$Error[0]`.