Solved

Accessing attributes within KvExt tables

  • 24 October 2023
  • 2 replies
  • 97 views

Userlevel 4
Badge +1

Hello, 

I’ve added an attribute to the Customer screen and an attribute to the Location screen.

Attributes on the Customer screen. 

Attributes on the Location screen.

I’ve finding that the attribute data is being saved to two different places.
The customer attributes are saved to the CSAnswers table. I can access this easily. 
The location attributes are saved to the LocationKvExt table. I don’t know how to access data in these KvExt tables.

PXGraph p = new PXGraph();
Location location = p.Select<Location>().FirstOrDefault(x => x.LocationID == ardoc.CustomerLocationID);
CSAnswers cSAnswersLocationANACode = p.Select<CSAnswers>().FirstOrDefault(x => x.RefNoteID == location.NoteID && x.AttributeID == "CHGLLOCEAN");

I use the code above to access the attribute from the CSAnswers table - does anyone know how to access the data from LocationKvExt?

icon

Best answer by Zoltan Febert 28 October 2023, 00:11

View original

2 replies

Userlevel 6
Badge +3

You can access these attributes via GetValueExt / SetValueExt functions.

I supposed your attribute’s name is “EAN”. Please note the “Attribute” prefix in the code sample.

PXGraph p = new PXGraph();
Location location = p.Select<Location>().FirstOrDefault(x => x.LocationID == ardoc.CustomerLocationID);

var attributeValue = (PXStringState)p.Caches[typeof(Location)].GetValueExt(location, "AttributeEAN");

 

Userlevel 4
Badge +1

Thank you @Zoltan Febert 

Golden answer. Works perfectly. Thank you for sharing your knowledge. 

I had figured out a workaround, and although it worked, it was pretty horrendous. Your one line solution is far, far cleaner.

Thank you 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved