Solved

How to access Customer User-Defined Field in a new Processing screen View Delegate


Userlevel 4
Badge

Hi Team,

I have create a new processing screen and in view delegate trying to access a Use Defined Field value from Customer screen to show on UI and I am using 22.106.0015 build version.

 

I have referred some community posts but not been able to access the defined field value. Below are the samples I have verified:

 public sealed class SOLineExt : PXCacheExtension<SOLine>
    {
        public static bool IsActive() { return true; }

 #region UsrEmployer
        [PXString()]
        [PXUIField(DisplayName = "Employer")]
        public string UsrEmployer { get; set; }
        public abstract class usrEmployer : PX.Data.BQL.BqlString.Field<usrEmployer> { }
        #endregion

}

 

public class LineProcessMaint : PXGraph<LineProcessMaint>
    {
        #region Views
        public PXCancel<SOLine> Cancel;
        public PXProcessing<SOLine> KitAssemblyProcess;

        #endregion
        
        protected IEnumerable kitAssemblyProcess()
        {
        foreach (PXResult<SOLine, SOOrder, SOShippingContact, InventoryItem> result in PXSelectJoin<SOLine, InnerJoin<SOOrder, On<SOOrder.orderType, Equal<SOLine.orderType>, And<SOOrder.orderNbr, Equal<SOLine.orderNbr>>>,
                                            InnerJoin<SOShippingContact, On<SOShippingContact.contactID, Equal<SOOrder.shipContactID>>,
                                            InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>>>,
                                            Where<InventoryItem.kitItem, Equal<True>>, OrderBy<Desc<SOLine.orderNbr>>>.Select(this))
            {
            SOLine line = result;
                SOOrder order = result;
                SOShippingContact shippingContact = result;
                InventoryItem inv = result;       
                SOLineExt lineExt = line?.GetExtension<SOLineExt>();
                 BAccount bAccount = PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(this, order?.CustomerID);
                PXCache cache = base.Caches[typeof(BAccount)];
                var attributeEMPLOYER = (PXStringState)cache.GetValueExt(bAccount, "AttributeEMPLOYER");

                
                 lineExt.UsrEmployer = attributeEMPLOYER;
            }
        }
        
        }

 

Can you please review and help, Thank you in Advance !

icon

Best answer by Naveen Boga 17 May 2023, 19:18

View original

4 replies

Userlevel 4
Badge

Thank you for the details @Naveen Boga 

Sure, I can check with that.

Userlevel 7
Badge +18

Hi @vivekm  Yes, I too have this my mind but I don’t think we have another approach to fetch the UDF field value.

But I suggest an alternate solution for your customization to avoid the performance issue, check if this can works for you.

You can have the internal field for the UDF field in the SOOrder Extension, and add logic to when UDF is added, your internal field should be updated accordingly. For old records, you can run a script.

So that, in this processing you can fetch the field value simply from SOOrder DAC.

 

Hope this helps!

Userlevel 4
Badge

Hi @Naveen Boga thank you for the details. 

I also verified with same and it worked as expected but the only concern I have with this approach is the Customer Graph Initialization. As we are working with view delegate, so the graph initialization may delay the data load significantly. 

Can you please suggest if there is another way to achieve this.

Userlevel 7
Badge +18

@vivekm  I have not verified this but can you try like below and verify.  

 public class LineProcessMaint : PXGraph<LineProcessMaint>
{
#region Views
public PXCancel<SOLine> Cancel;
public PXProcessing<SOLine> KitAssemblyProcess;

#endregion

protected IEnumerable kitAssemblyProcess()
{
CustomerMaint customerGraph = PXGraph.CreateInstance<CustomerMaint>();
foreach (PXResult<SOLine, SOOrder, SOShippingContact, InventoryItem> result in PXSelectJoin<SOLine, InnerJoin<SOOrder, On<SOOrder.orderType, Equal<SOLine.orderType>, And<SOOrder.orderNbr, Equal<SOLine.orderNbr>>>,
InnerJoin<SOShippingContact, On<SOShippingContact.contactID, Equal<SOOrder.shipContactID>>,
InnerJoin<InventoryItem, On<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>>>,
Where<InventoryItem.kitItem, Equal<True>>, OrderBy<Desc<SOLine.orderNbr>>>.Select(this))
{
customerGraph.Clear();
SOLine line = result;
SOOrder order = result;
SOShippingContact shippingContact = result;
InventoryItem inv = result;
SOLineExt lineExt = line?.GetExtension<SOLineExt>();

customerGraph.BAccount.Current = PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>.Select(this, order?.CustomerID);

var row = customerGraph.BAccount.Current;
var cache = customerGraph.BAccount.Cache;

var attributeEMPLOYER = (PXStringState)cache.GetValueExt(bAccount, "AttributeEMPLOYER");

lineExt.UsrEmployer = attributeEMPLOYER;
}
}

}

 

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