Check-Items
This function is executed when clicking the “Check” button within the Item Tab.
All the Items from the BOM Window can be checked against ERP.
Syntax
Check-Items [-Items] <Item[]>
Parameters
Type |
Name |
Description |
input/output |
Mandatory |
Default value |
---|---|---|---|---|---|
Item [] |
Items |
The Items which should be checked |
input |
yes |
Return type
void
Remarks
Each unique Item shown in the BOM Window will be passed to this function.
It’s 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 Check operation.
The Status of all the Items that where not updated, gets automatically changed to Unknown.
Examples
Checking whether Vault Items exist in the ERP system: Items are marked as “New”, “Identical” and with “Error” icons:
function Check-Items($items) {
foreach($item in $items) {
if(-not $item._PartNumber) {
$item | Update-BomWindowEntity -Status 'Error' -StatusDetails 'Number is empty'
}
$erpItem = Get-ERPObject -EntitySet 'Materials' -Keys @{'Number' = $item._PartNumber} -Expand 'Descriptions'
if($? -and -not $erpItem) {
$item | Update-BomWindowEntity -Status 'New' -StatusDetails 'Item does not exist in ERP'
}
if($erpItem) {
$item | Update-BomWindowEntity -Status 'Identical' -StatusDetails 'Item exists in ERP'
}
}
}
Note: In case of connection problems during the Get-ERPObject cmdlet, the status of the currently iterated $item
object is automatically set to ‘Error’.
Further exception details can be retrieved via automatic variables like $?
and $Error[0]
.