Skip to main content
Solved

Non Project Code Validation

  • Feb 3, 2021 7:54 AM UTC
  • 2 replies
  • 346 views
  • Translate All

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.

Best answer by Cesar Betances

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
}

 

View original

2 replies

Forum|alt.badge.img+2
  • Acumatica Moderator
  • Answer
  • Feb 16, 2021 6:36 PM UTC

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
}

 

Translate

Forum|alt.badge.img
  • Jr Varsity I
  • Aug 26, 2021 5:30 PM UTC

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

 

Translate