Skip to main content
Question

Populate a field on selector field update.


param2022
Jr Varsity II
Forum|alt.badge.img
[PXInt()]
[PXUIField(DisplayName = "Picker", Required = false, Enabled = true, Visibility = PXUIVisibility.SelectorVisible)]
[PXDefault]
[PXSelector(typeof(Search<EPEmployee.bAccountID>),
            typeof(EPEmployee.bAccountID), typeof(EPEmployee.acctName))]
public int? Picker { get; set; }
public abstract class picker : PX.Data.BQL.BqlInt.Field<picker> { }

[PXString()]
[PXUIField(DisplayName = "Picker Name", Required = false, Enabled = false)]
public string PickerName { get; set; }
public abstract class pickerName : PX.Data.BQL.BqlString.Field<pickerName> { }

EPEmployee class contains the acctName field which I want to populate in pickerName when the Picker is selected by the selector.

How can I do that ??

11 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3377 replies
  • June 6, 2022

Hi @param2022  You can write a PXDefault<> for the Picker Name and fetch the AcctName, based on the current selected BAccountID in the Picker field.

Like below 

Eg: 

Add below PXDefault attribute to the PickerName field

   [PXDefault(typeof(Search<BAccount.acctname, Where<BAccount.baccountID, Equal<Current<YOURDACName.picker >>>>))]


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • June 6, 2022
[PXString()]
        [PXUIField(DisplayName = "Picker", Required = false, Enabled = true, Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault]
        [PXSelector(typeof(Search<EPEmployee.acctCD>),
            typeof(EPEmployee.bAccountID), typeof(EPEmployee.acctName))]
        public string Picker { get; set; }
        public abstract class picker : PX.Data.BQL.BqlString.Field<picker> { }

        [PXString()]
        [PXUIField(DisplayName = "Picker Name", Required = false, Enabled = false)]
        [PXDefault(typeof(Search<EPEmployee.acctName, Where<EPEmployee.acctCD, Equal<Current<HeaderExt.picker>>>>))]
        public string PickerName { get; set; }
        public abstract class pickerName : PX.Data.BQL.BqlString.Field<pickerName> { }

I did as you said @Naveen Boga but it did not work.
I also tried using PXFormula


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3377 replies
  • June 6, 2022

@param2022  It seems there is a mistake in your code. Try like below.

 

[PXDefault(typeof(Search<EPEmployee.acctName, Where<EPEmployee.baccountID, Equal<Current<HeaderExt.picker>>>>))]


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • June 7, 2022

@Naveen Boga I changed the field in selector so I was using acctCD instead of bAccountID


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • June 8, 2022

@Naveen Boga can you suggest anything else ??


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3377 replies
  • June 8, 2022

Hi @param2022  Better you can take BAccountID instead of acctCD.

Searching should be with BAccountID and you can add the Substitute Key for AcctCD to display on the selector field.

You can modify the code like below and verify.

  #region Picker
        [PXString()]
        [PXUIField(DisplayName = "Picker", Required = false, Enabled = true, Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault()]
        [PXSelector(typeof(Search<EPEmployee.bAccountID>),
            typeof(EPEmployee.bAccountID), typeof(EPEmployee.acctName), SubstituteKey = typeof(EPEmployee.acctCD))]
        public string Picker { get; set; }
        public abstract class picker : PX.Data.BQL.BqlString.Field<picker> { }
        #endregion


        #region PickerName
        [PXString()]
        [PXUIField(DisplayName = "Picker Name", Required = false, Enabled = false)]
        [PXDefault(typeof(Search<EPEmployee.acctName, Where<EPEmployee.bAccountID, Equal<Current<HeaderExt.picker>>>>))]
        public string PickerName { get; set; }
        public abstract class pickerName : PX.Data.BQL.BqlString.Field<pickerName> { }
        #endregion

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • June 8, 2022

@Naveen Boga I have tried the exact code you provided and it is still not working. Can this be an issue related to Current<> we are using over here ?

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3377 replies
  • June 8, 2022

Hi, @param2022  I have added these fields in the Customers screen and verified with the below and it is working fine. Please find the code below for your reference.

 

using PX.Data;
using PX.Objects.AR;
using PX.Objects.EP;
using System;

public class BAccountExt : PXCacheExtension<PX.Objects.CR.BAccount>
    {
        #region Picker
        [PXInt()]
        [PXUIField(DisplayName = "Picker", Required = false, Enabled = true, Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault()]
        [PXSelector(typeof(Search<EPEmployee.bAccountID>),
            typeof(EPEmployee.bAccountID), typeof(EPEmployee.acctName), SubstituteKey = typeof(EPEmployee.acctCD))]
        public int? Picker { get; set; }
        public abstract class picker : PX.Data.BQL.BqlInt.Field<picker> { }
        #endregion


        #region PickerName
        [PXString()]
        [PXUIField(DisplayName = "Picker Name", Required = false, Enabled = false)]
        [PXDefault(typeof(Search<EPEmployee.acctName, Where<EPEmployee.bAccountID, Equal<Current<BAccountExt.picker>>>>))]
        public string PickerName { get; set; }
        public abstract class pickerName : PX.Data.BQL.BqlString.Field<pickerName> { }
        #endregion
    }

    public class CustomerMaintExt : PXGraphExtension<CustomerMaint>
    {
        protected virtual void Customer_Picker_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)// PXFieldDefaulting InvokeBaseHandler)
        {             
            var row = (Customer)e.Row;
            if (row == null) return;
            BAccountExt ext = row.GetExtension<BAccountExt>();            
            EPEmployee obj = PXSelect<EPEmployee, Where<EPEmployee.bAccountID, Equal<Required<BAccountExt.picker>>>>.Select(Base, ext?.Picker);
            ext.PickerName = obj?.AcctName;
        }
    }

 

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • June 8, 2022

I an adding this in Pick Pack and Ship screen so i need scanheader extension class added my whole DAC extension here @Naveen Boga 

public class HeaderExt : PXCacheExtension<ScanHeader>
    {
        [PXString()]
        [PXUIField(DisplayName = "Scanner", Required = false, Enabled = false)]
        [PXEPEmployeeSelector]
        [PXUnboundDefault(typeof(Search<EPEmployee.acctCD,
                 Where<EPEmployee.userID, Equal<Current<AccessInfo.userID>>>>))]
        public string Scanner { get; set; }
        public abstract class scanner : PX.Data.BQL.BqlString.Field<scanner> { }

        [PXString()]
        [PXUIField(DisplayName = "Scanner Name", Required = false, Enabled = false)]
        [PXEPEmployeeSelector]
        [PXUnboundDefault(typeof(Search<EPEmployee.acctName,
                 Where<EPEmployee.userID, Equal<Current<AccessInfo.userID>>>>))]
        public string ScannerName { get; set; }
        public abstract class scannerName : PX.Data.BQL.BqlString.Field<scannerName> { }

        #region Picker
        [PXString()]
        [PXUIField(DisplayName = "Picker", Required = false, Enabled = true, Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault()]
        [PXSelector(typeof(Search<EPEmployee.bAccountID>),
            typeof(EPEmployee.bAccountID), typeof(EPEmployee.acctName))]
        public string Picker { get; set; }
        public abstract class picker : PX.Data.BQL.BqlString.Field<picker> { }
        #endregion


        #region PickerName
        [PXString()]
        [PXUIField(DisplayName = "Picker Name", Required = false, Enabled = false)]
        //[PXDefault(typeof(Search<EPEmployee.acctName, Where<EPEmployee.bAccountID, Equal<Current<HeaderExt.picker>>>>))]
        [PXFormula(typeof(Search<EPEmployee.acctName, Where<EPEmployee.bAccountID, Equal<Current<HeaderExt.picker>>>>))]
        public string PickerName { get; set; }
        public abstract class pickerName : PX.Data.BQL.BqlString.Field<pickerName> { }
        #endregion

        [PXString()]
        [PXUIField(DisplayName = "Scanning Status", Required = false, Enabled = false)]
        [PXDefault(TypeCode.String, "Not Started")]
        public string ScanningStatus { get; set; }
        public abstract class scanningStatus : PX.Data.BQL.BqlString.Field<scanningStatus> { }
    }

 


param2022
Jr Varsity II
Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 94 replies
  • June 8, 2022

@Naveen Boga  do you this this issue is because I am accessing BAccount in ScanHeader DACExtension ?


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • 2622 replies
  • July 25, 2022

Hi @param2022 - were you ever able to find a solution for this issue? Thank you!


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