Solved

Non Project Code Validation

  • 3 February 2021
  • 2 replies
  • 100 views

I am trying to perform validation on the project for screen EP307000.

 

Under Project Preferences we have defined the non project code as ‘X’.


What I want to achieve is to prevent users from saving their time entry when they have not selected their project, and it defaults on ‘X’.

I would appreciate any help.

icon

Best answer by Cesar Betances 16 February 2021, 19:36

View original

2 replies

If you are trying to add validation at the moment the user presses the Save button on your screen, you could try to add your validation on Persist() method. You could:

-Create graph extension of that screen’s graph.

-Override Persist() method.

-On this override you will add your validation, and then call base(persist) method, similar to this:

 


[PXOverride]
public void Persist(Action baseMethod)
{
if( YourValidationFailed) throw new Exception("Fail!"); //Add your validation code

baseMethod(); //Call base method
}

 

Userlevel 1

I was able to solve this for Expense Receipts using a customization:

namespace PX.Objects.EP
{
public class ExpenseClaimDetailEntry_Extension : PXGraphExtension<ExpenseClaimDetailEntry>
{
#region Event Handlers

protected virtual void EPExpenseClaimDetails_contractID( Events.FieldVerifying<EPExpenseClaimDetails.contractID> e)
{

if (e != null)
{

if ((int)e.NewValue == 0)
{
throw new PXSetPropertyException("Non-Project Code XXXXXXXX cannot be used in expense reciepts.", PXErrorLevel.RowError);
}
}
}

#endregion
}
}

 

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 — 2020  Acumatica, Inc. All rights reserved