Solved

Account selector showing the AccountID instead of the AccountCD

  • 21 March 2023
  • 7 replies
  • 103 views

Userlevel 1
Badge

I have added a new custom field that allows user to select an account. For that I have used existing Account attribute.

[Account(DisplayName = "Account", BqlField = typeof(INTranExt.usrAccount), Visibility = PXUIVisibility.Visible, Filterable = false, DescriptionField = typeof(Account.description), Required = false, AvoidControlAccounts = true)]
public virtual int? UsrAccount { get; set; }
public abstract class usrAccount : PX.Data.BQL.BqlInt.Field<usrAccount> { }

I have a field validating event on this field. When it returns an error is shows the AccountID instead of the AccountCD. How can is solve that. Can anyone please provide an insight here.

icon

Best answer by Vinay Koppula 21 March 2023, 16:07

View original

7 replies

Userlevel 5
Badge +1

@tanuj81 share the code in the field validating event as well to review. 

Userlevel 1
Badge
protected void INTran_UsrAccount_FieldVerifying(PXCache cache, PXFieldVerifyingEventArgs e)
{
// logic for calculation
if (!isAccountInAccountGroup)
{
e.Cancel = true;
throw new PXSetPropertyException(Messages.Test);
}
}

@Vinay Koppula But i don't think issue is here but you can have a look, Because the error is thrown perfectly as per the logic. I debugged the code and it is working fine. But in UI it shows AccountID in red text, not the AccountCD

Userlevel 5
Badge +1

@tanuj81  Issue is in the Field Verifying event code only, you are assuming it will automatically display AccountCD but the fact is we have to pass value to display in the field. 

 

Sample code that you put in the event code:

PX.Objects.GL.Account Act = PXSelect<PX.Objects.GL.Account, Where<PX.Objects.GL.Account.accountID,                 Equal<Required<PX.Objects.GL.Account.accountID>>>>.Select(Base, e.NewValue);

e.NewValue = Act?.AccountCD;
throw new PXSetPropertyException("Message.Test");

 

Userlevel 5
Badge +1

Another way to raise an exception and pass the AccountCD to display. 

cache.RaiseExceptionHandling<INTranExt.usrAccount >(e.Row, Act?.AccountCD, new PXSetPropertyException(errorMsg, PXErrorLevel.Error));

 

@tanuj81  Issue is in the Field Verifying event code only, you are assuming it will automatically display AccountCD but the fact is we have to pass value to display in the field. 

 

Sample code that you put in the event code:

PX.Objects.GL.Account Act = PXSelect<PX.Objects.GL.Account, Where<PX.Objects.GL.Account.accountID,                 Equal<Required<PX.Objects.GL.Account.accountID>>>>.Select(Base, e.NewValue);

e.NewValue = Act?.AccountCD;
throw new PXSetPropertyException("Message.Test");

 

Yes, I have reviewed in my case and it worked.

Thanks

Userlevel 1
Badge

@Vinay Koppula Thanks for such a detailed answer. 

Userlevel 5
Badge +1

@tanuj81 You are welcome! 

Thanks @sajids  for confirming.  

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