Solved

Making Description field on Journal Transactions required

  • 19 October 2021
  • 3 replies
  • 138 views

Userlevel 6
Badge +3

I am trying to make the Description field on the Journal Transactions screen required, but only if the entry is being created on the Journal Transactions screen.  I don’t want to stop sub ledgers from posting entries if no description is provided.  For example, if someone creates a payables invoice without a description, I don’t want to cause the transaction to not post to the GL if the payables transaction does not have a description.

I added the red asterisk to the field.  Obviously, that doesn’t make the field required, but just shows that it is required.

Here is the event I am firing to try to make this happen:

    public class JournalEntry_Extension : PXGraphExtension<JournalEntry> 

    {

        protected void _RowUpdating(Events.RowUpdating<Batch> e)
        {
            var row = (Batch)e.Row;
            if (row == null) return;
            if (row.Module == “GL”)
            {
                if (row.Description == null)
                {
                    //throw new PXSetPropertyException(ICInterTenant.Messages.DescriptionIsRequired);
                    //throw new PXException(ICInterTenant.Messages.DescriptionIsRequired);
                    throw new Exception(ICInterTenant.Messages.DescriptionIsRequired);
                }
            }
        }

   }

When I debug this, if the entry is coming from the Journal Transactions screen, it fires and the Exception is raised in the code.  However, you can still save the entry and no messages appear on the screen.

What am I doing wrong?

Thanks in advance for all your help!

Joe

 

icon

Best answer by Joe Schmucker 19 October 2021, 22:09

View original

3 replies

Userlevel 6
Badge +3

I think I got it.  This seems to be working.

        protected void Batch_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null) return;
            var row = (Batch)e.Row;
            if (row.Module == "GL")
            {
                if (row.Description == null)
                {
                    throw new Exception(ICInterTenant.Messages.DescriptionIsRequired);
                }
            }
        }
 

Is there a way for this to be done without a customization? I was thinking approval map that would require approval if the description is empty. I have a customer that would like to be able to implement the same requirement “JE Description cannot be blank”. Just wondering if there is a process that can be easily done by the end user?

Userlevel 6
Badge +3

 @ahillyer32 I was unable to get it to work with workflows.  I tried hard, believe me.  If you want to include the code I used above in your project, you can do so as follows:

In Project Editor, edit the GL screen.  

Select the “Form: BatchModule” from the tree

Under Events, find the RowPersisting handler and select the row

From the ADD HANDLER drop down, select Keep Base Method

 

 

The code editor will open.

Replace this code:

    protected void Batch_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
    {
      
      var row = (Batch)e.Row;
      
    }

with this code:

       protected void Batch_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null) return;
            var row = (Batch)e.Row;
            if (row.Module == "GL")
            {
                if (row.Description == null)
                {
                    throw new Exception(ICInterTenant.Messages.DescriptionIsRequired);
                }
            }
        }

Save and publish your project.

That should do the trick.  

 

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