1. You did customization on the form Company/Inventory and warehouse management/Common/On-hand inventory.
How this form customization will affect on the form Inventory Management->Inquiries-> On-Hand->Transactions and Intercompany on Hand screens?
2. Try the same code logic on the form Inventory Management->Inquiries-> On-Hand->Transactions and Intercompany on Hand screens.
3. If the itemid is not showing then set true value to the itemid flag.
inventdimparmvisible.InventLocationIdFlag = true;
inventdimparmvisible.ItemIdFlag = true;