Skip to main content
Solved

Accessing attributes within KvExt tables

  • October 24, 2023
  • 2 replies
  • 516 views
  • Translate All

Forum|alt.badge.img+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?

Best answer by Zoltan Febert

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");

 

View original

2 replies

Zoltan Febert
Jr Varsity I
Forum|alt.badge.img+4

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");

 

Translate

Forum|alt.badge.img+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 

Translate