Skip to main content
Solved

Making Description field on Journal Transactions required

  • October 19, 2021
  • 3 replies
  • 233 views

Joe Schmucker
Captain II
Forum|alt.badge.img+2

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

 

Best answer by Joe Schmucker

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

View original
Did this topic help you find an answer to your question?

3 replies

Joe Schmucker
Captain II
Forum|alt.badge.img+2
  • Author
  • Captain II
  • 456 replies
  • Answer
  • October 19, 2021

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


  • Freshman I
  • 8 replies
  • February 8, 2024

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?


Joe Schmucker
Captain II
Forum|alt.badge.img+2
  • Author
  • Captain II
  • 456 replies
  • February 9, 2024

 @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


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