0
votes

Made the journal entry description field mandatory with below code: using PX.Objects.CR; using PX.Data.EP;

using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using PX.Api;
using PX.Data;
using PX.Common;
using PX.Objects.Common;
using PX.Objects.CS;
using PX.Objects.CM;
using PX.Objects.CA;
using PX.Objects.FA;
using PX.Objects.GL.JournalEntryState;
using PX.Objects.GL.JournalEntryState.PartiallyEditable;
using PX.Objects.GL.Overrides.PostGraph;
using PX.Objects.GL.Reclassification.UI;
using PX.Objects.PM;
using PX.Objects.TX;
using PX.Objects;
using PX.Objects.GL;

namespace PX.Objects.GL
{

  public class JournalEntry_Extension:PXGraphExtension<JournalEntry>
  {

    #region Event Handlers
    //start my code
    [PXDefault]
    [PXCustomizeBaseAttribute(typeof(PXUIFieldAttribute), "Required", true)]
    //end my code

    [PXUIField(DisplayName = "Description", Visibility = PXUIVisibility.Visible)]
    [PXDBString(255, IsUnicode = true)]
    protected virtual void Batch_Description_CacheAttached(PXCache cache)
    {

    }





    #endregion

  }


}

however, I receive an error message when browsing records as below: enter image description here

Error: Error: An error occurred during processing of the field Description : Unable to cast object of type 'System.Boolean' to type 'System.String'..

Not sure what I'm doing wrong Thanks

1

1 Answers

2
votes

You could set the Required property to True using PXUIField Attribute. See sample below (Please notice that there are NO quotes on Required Property):

public class JournalEntry_Extension : PXGraphExtension<JournalEntry>
{

    #region Event Handlers
    [PXDefault]
    [PXUIField(DisplayName = "Description", Visibility = PXUIVisibility.Visible, Required = true)]
    [PXDBString(255, IsUnicode = true)]
    protected virtual void Batch_Description_CacheAttached(PXCache cache)
    {

    }
    #endregion
}