Skip to main content
Solved

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


vivekm
Varsity I
Forum|alt.badge.img

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 !

Best answer by Naveen Boga

@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;
            }
        }

    }

 

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

4 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • Answer
  • May 17, 2023

@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;
            }
        }

    }

 


vivekm
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • 78 replies
  • May 18, 2023

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.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • May 18, 2023

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!


vivekm
Varsity I
Forum|alt.badge.img
  • Author
  • Varsity I
  • 78 replies
  • May 18, 2023

Thank you for the details @Naveen Boga 

Sure, I can check with that.


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