Solved

Access User Defined Field from business logic

  • 3 April 2023
  • 3 replies
  • 234 views

Userlevel 1
Badge

Hello,

 

I have a user defined field Workorder, that I need to access from some business logic. How do I do this?

 

Thanks

 

icon

Best answer by Vignesh Ponnusamy 3 April 2023, 23:29

View original

3 replies

Userlevel 6
Badge +4

Hi @DoShawhan 

User Defined fields are based on attributes and stored in a sibling table. For example for 

FSAppointment  you have the table FSAppointmentKvExt

You can create a DAC for that table and query it. Fields have a prefix ‘Attribute’ tied and it is link to the parent entity by NoteID - RecordID. Also you can see the definition in the table CSScreenAttribute

SQL Server queries

Remember that all user defined fields are linked to attributes. The way you define them is the way the data will be stored.

Hope this help

 

Userlevel 7
Badge +4

Hello @DoShawhan, To access the value from the graph you can try using cache.GetValueExt. Below is an example,

       protected void SOOrder_RowPersisting(PXCache cache, PXRowPersistingEventArgs e, PXRowPersisting baseevent)
        {
            if (baseevent != null)
                baseevent(cache, e);
            SOOrder row = (SOOrder)Base.Document.Current;
            //var Itemcache = Base.Document.Cache;
            var udfAMBATLEN = (PXStringState)cache.GetValueExt(row, "AttributeAMBATLEN");
            if (Base.Document.Current.OrderQty > 5)
            {
                cache.SetValueExt(row, "AttributeAMBATLEN", "Greater than 5"); //To set the value of attri
            }
            else
            {
                cache.SetValueExt(row, "AttributeAMBATLEN", "Less than 5");
            }
        }

Note: If you have the AttributeID ProjectCategories, you should prefix it with the Attribute(like AttributeProjectCategories) in the GetValueExt. 

Thanks, Vignesh

Userlevel 6
Badge +3

In case you are trying to READ the values in a UDF, this is the code I used.  My UDF is a multi-select DDL so I split the values.  If the value in one of your multi-select items has a comma, that will cause an issue.  I don’t have that in my case.

PXFieldState udfValue = (PXFieldState)cache.GetValueExt(order, "AttributeHOLDID");
if (udfValue == null || udfValue.Value == null) return;

string[] values = udfValue.Value.ToString().Split(',');

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