Skip to main content
Solved

Select MatrixInventoryItem with BQL


Forum|alt.badge.img+1

I’m trying to select MatrixInventoryItem record inside a static process.  I have the corresponding InventoryItem which I thought I could just cast as MatrixInventoryItem but was not able to.  

I have this for my BQL:

MatrixInventoryItem matrixItem = PXSelect<MatrixInventoryItem,
      Where<MatrixInventoryItem.inventoryID, Equal<Required<MatrixInventoryItem.inventoryID>>>>
     .Select(itemGraph, item.InventoryID);

If I debug this I see that item.InventoryID does have a value.

In SQL profiler, I’m seeing this WHERE clause which returns no rows:

FROM [InventoryItem] [MatrixInventoryItem]
WHERE ( [MatrixInventoryItem].[CompanyID] = 2) AND [MatrixInventoryItem].[DeletedDatabaseRecord] = 0 AND (NULL = @P0) OPTION(OPTIMIZE FOR UNKNOWN)',N'@P0 int',@P0=675

But expecting this, which does return the row I need:

FROM [InventoryItem] [MatrixInventoryItem]
WHERE ( [MatrixInventoryItem].[CompanyID] = 2) AND [MatrixInventoryItem].[DeletedDatabaseRecord] = 0 AND ([MatrixInventoryItem].[InventoryID] = @P0) OPTION(OPTIMIZE FOR UNKNOWN)',N'@P0 int',@P0=675

What am I doing wrong?

Best answer by rjean09

I wound up just using the Answers view on InventoryItemMaint graph to get the matrix code/values that I need:

 

 itemGraph.Item.Current = item;

var matrixOptions = itemGraph.Answers.Select(itemGraph).ToList();

string[] attributeValues = matrixOptions.Select(result => (CSAnswers)result).ToList().Select(x => x.Value).ToArray();
string[] attributeIDs = matrixOptions.Select(result => (CSAnswers)result).ToList().Select(x => x.AttributeID).ToArray();

 

View original
Did this topic help you find an answer to your question?

4 replies

hdussa
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • 99 replies
  • October 2, 2024

Hello @rjean09 ,

 

MatrixInventoryItem is a Virtual DAC so try using a view delegate to fill in the cache or select records.

Hope this helps!


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • 77 replies
  • October 2, 2024
hdussa wrote:

Hello @rjean09 ,

 

MatrixInventoryItem is a Virtual DAC so try using a view delegate to fill in the cache or select records.

Hope this helps!

I’m not currently trying to select this for a view.  I have a view of InventoryItem of the template items I want to process and show in the grid. Within the process I just want to get from the data store (or cast if that’s possible) the corresponding MatrixInventoryItem so that I have access to the attribute arrays as I don’t see these on the InventoryItem itself.  I suppose I could still create a view/view delegate for doing this but I’m still not sure how to fill a single/list of MatrixInventoryItem


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • 77 replies
  • Answer
  • October 3, 2024

I wound up just using the Answers view on InventoryItemMaint graph to get the matrix code/values that I need:

 

 itemGraph.Item.Current = item;

var matrixOptions = itemGraph.Answers.Select(itemGraph).ToList();

string[] attributeValues = matrixOptions.Select(result => (CSAnswers)result).ToList().Select(x => x.Value).ToArray();
string[] attributeIDs = matrixOptions.Select(result => (CSAnswers)result).ToList().Select(x => x.AttributeID).ToArray();

 


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2754 replies
  • October 3, 2024

Thank you for sharing your solution with the community @rjean09!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings