Transfer-Items

This function is executed when clicking the “Transfer” button within the Item Tab.
All the Items from the BOM Window can be transferred to to ERP.

Syntax

Transfer-Items [-Items] <Item[]>

Parameters

Type

Name

Description

input/output

Mandatory

Default value

Item []

Items

The Items which should be transfered

input

yes

Return type

void

Remarks

Each unique Item shown in the BOM Window with another Status then Unknown will be passed to this function.

It is recommended to update the Status of all the Items with the Update-BomWindowEntity cmdlet.
Only in case of connection problems with ERP cmdlets the status of the according items 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 Status of all the Items that where not updated, gets automatically changed to Unknown.

Examples

Removing all the Vault Items with Status “Remove” in ERP: after successful deletion the Item disappears in the BOM Window, otherwise it is marked as “Error”:

function Transfer-Items($items) {
   foreach($item in $items) {
      if($item._Status -eq 'Remove'){
         $removed = Remove-ERPObject -EntitySet 'Materials' -Keys @{'Number'=$item._PartNumber}
         if($removed) {
            $item | Remove-BomWindowEntity
         }
         else {
            $item | Update-BomWindowEntity -Status 'Error' -StatusDetails "Error occured when removing item: $($Error[0].Exception.Message)"
         }
      }
   }
}

Note: In case of connection problems during the Remove-ERPObject cmdlet, the status of the currently iterated $item object is automatically set to ‘Error’ but it can still be assigned manually.
Exception details can be retrieved via automatic variables like $? and $Error[0].