Skip to main content
Solved

Non Project Code Validation

  • 3 February 2021
  • 2 replies
  • 242 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.

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
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+2
  • Acumatica Moderator
  • 43 replies
  • Answer
  • February 16, 2021

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
}   

 


Forum|alt.badge.img
  • Jr Varsity I
  • 16 replies
  • August 26, 2021

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


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