# Check-Boms This function is executed when clicking the "Check" button within the [BOM Tab](/bom_window).\ All the [BOMs](/code_reference/commandlets/show-bomwindow/objects/bom) from the BOM Window can be checked against ERP. ## Syntax ```powershell Check-Boms [-Boms] ``` ## Parameters | Type | Name | Description | input/output | Mandatory | Default value | |--------------------------------------------------------------------|------|----------------------------------|--------------|-----------|---------------| | [Bom](/code_reference/commandlets/show-bomwindow/objects/bom) \[\] | Boms | The Boms which should be checked | input | yes | | ## Return type **void** ## Remarks Each **unique** [BOM](/code_reference/commandlets/show-bomwindow/objects/bom) shown in the BOM Window is passed to this function. It's recommended to update the [status](/bom_window/status) of all the BOMs and their rows with the [](/code_reference/commandlets/show-bomwindow/commandlets/update-bomwindowentity) cmdlet. When an exception is thrown within this function, the BOM Window {ref}`shows the Exception ` message of the terminated Check operation.\ The [status](/bom_window/status) of all the [BOMs](/code_reference/commandlets/show-bomwindow/objects/bom) and their *Children* that where not updated, gets automatically changed to *Unknown*. ## Examples **Setting Status and StatusDetails of all the file BOMs that exist in ERP to "Identical" or otherwise to "New":** ```powershell function Check-Boms($boms) { foreach($vaultBom in $boms) { $erpBom = Get-ERPObject -EntitySet "Boms" -Keys @{ "ParentNumber"= $vaultBom.Bom_Number } -Expand "Children" if($erpBom -eq $null) { Update-BomWindowEntity -InputObject $vaultBom -Status New -StatusDetails 'BOM does not exist in ERP' } else { Update-BomWindowEntity -InputObject $vaultBom -Status Identical -StatusDetails 'BOM exists in ERP' } } } ``` **Checking if the File BomRows are "Identical" as on the ERP-BOMs, if there are "New" once or rows that should be "Removed"** ```powershell function Check-Boms($boms) { foreach($vaultBom in $boms) { $erpBom = Get-ERPObject -EntitySet "Boms" -Keys @{ "ParentNumber"= $vaultBom.Bom_Number } -Expand "Children" #iterating ERP-BOM rows and checking if they exist in the Vault-BOM if($erpBom.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 -ne $null) { Update-BomWindowEntity -InputObject $vaultBomRow -Status Identical } else { $bomRow = Add-BomWindowEntity -Type BomRow -Parent $vaultBom -Properties @{"Bom_Number"=$erpBomRow.ChildNumber;"Bom_PositionNumber"=$erpBomRow.Position; "Bom_Quantity"=$erpBomRow.Quantity;} Update-BomWindowEntity -InputObject $bomRow -Status Remove } } } #iterating Vault-BOM rows and checking if they exist in the ERP-BOM if($vaultBom.Children) { foreach($vaultBomRow in $vaultBom.Children) { $erpBomRow = $erpBom.Children | Where-Object { $_.ChildNumber -eq $vaultBomRow.Bom_Number -and $_.Position -eq $vaultBomRow.Bom_PositionNumber } | select -First 1 if( $erpBomRow -eq $null) { Update-BomWindowEntity -InputObject $vaultBomRow -Status New } } } } } ```