I am trying to create a customization to iterate through inventory items to update Prices in a BigCommerce store from a custom field I created called usrAIWHLPrice on an InventoryItem extension.
I have created a new screen with a datasource which is based on a query that checks for that field not being null:
public SelectFrom<InventoryItem>
.Where<InventoryItemExt.usrAIWHLPrice.IsNotNull>
.View InvItems;
I am still getting to grips with how to do things in Acumatica so decided to just create a simple action as a first step that will create a list of inventoryitems I can iterate through and pull out the information I need.
I created a button with an action:
public PXAction<InventoryItem> prepareWHLData;
PXButton]
PXUIField(DisplayName = "Prepare WHL Data",
MapEnableRights = PXCacheRights.Select,
MapViewRights = PXCacheRights.Select)]
protected void PrepareWHLData()
{
PXTrace.WriteInformation("Preparing data...");
var invItems = SelectFrom<InventoryItem>
.Where<InventoryItemExt.usrAIWHLPrice.IsNotNull>
.View.Select(this);
if (invItems == null) {
PXTrace.WriteInformation("null items");
}
else
{
foreach (var item in invItems)
{
PXTrace.WriteInformation("items found:");
}
}
}
This validates and runs but when I click the button and step through it in Visual Studio the query throws an exception saying it’s a single record requested and only returns a single record instead of the three I’m expecting.
I’m presuming this is because of using View.Select(this) but I don’t know what else to put there that will get me a recordset containing the three expected records.
Can anyone give me a pointer?
Thanks for any help/advice,
Phil