Question

Populate a field on selector field update.


Userlevel 2
Badge
[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

Userlevel 7
Badge +17

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 >>>>))]

Userlevel 2
Badge
[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

Userlevel 7
Badge +17

@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>>>>))]

Userlevel 2
Badge

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

Userlevel 2
Badge

@Naveen Boga can you suggest anything else ??

Userlevel 7
Badge +17

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

 

Userlevel 2
Badge

@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 ?

 

Userlevel 7
Badge +17

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

 

 

Userlevel 2
Badge

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> { }
}

 

Userlevel 2
Badge

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

Userlevel 7
Badge

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

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