Skip to main content
Solved

Access User Defined Field from business logic


Forum|alt.badge.img

Hello,

 

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

 

Thanks

 

Best answer by Vignesh Ponnusamy

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

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

3 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+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

 


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

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


Joe Schmucker
Captain II
Forum|alt.badge.img+2

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


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