Skip to main content
Solved

Acumatica - Unable to show time in pxgrid

  • July 13, 2023
  • 1 reply
  • 91 views

amitr70
Semi-Pro I
Forum|alt.badge.img

 

I have a custom screen in Acumatica ERP 2022 R1, where I am importing excel. That excel has Specialized Test results. In that excel I have two columns StartTime and EndTime. These column are supposed to carry time values and in format HH:mm:ss. Now in my DAC the start time and endtime has been defined as int. See the codes below:

 

#region StartTime
    public abstract class startTime : PX.Data.BQL.BqlInt.Field<startTime>
    {
    }
    protected int? _StartTime;
    [PXDBInt()]
    [PXUIField(DisplayName = "Start Time")]
    [PXTimeList()]
    public virtual int? StartTime
    {
        get
        {
            return this._StartTime;
        }
        set
        {
            this._StartTime = value;
        }
    }
    #endregion

 Similar code is for EndTime except names. Now while importing , if i am using time in my excel the code was giving exception that 12/31/1899 05:16:11 AM cannot be converted to time.

 

I drilled down and found that this exception is coming from FieldUpdating event of PXTimeList attribute, where the code is unable to parse date thus raising exception. So I decompiled the code and created custom attribute making some modification in FieldUpdating event. I added additional codes for parsing and it worked. After excel getting imported perfectly fine and value is getting stored as Integer, but here comes another problem while binding value on the grid column, its showing the value in integer for any random time values. For time ending with 30 or 00 its workign fine. Below are the screenshots

  1. Value in excel
  1. Value in PxGrid after importing

enter image description here

Also I did have some changes in aspx level

  1. Tried setting DisplayFormat ="t" in Customization Project Editor

  2. Converted DropDownlist to PXTimeSpan

  3. Added attributes

    <px:PXGridColumn DataField="EndTime" TextAlign="Right" CommitChanges="true" TimeMode="true" RenderEditorText="True"> </px:PXGridColumn>

    <px:PXTimeSpan ID="edchEndTime" runat="server" DataField="EndTime" InputMask="hh:mm"> </px:PXTimeSpan>

So I need you to help me fix this. I am burning my eyes since last two days.

 

Please do note, I cannot change DAC or Database fields or their data type. I need solution in the same code base only.

Best answer by amitr70

Adding formatting values solved that issue. 

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

1 reply

amitr70
Semi-Pro I
Forum|alt.badge.img
  • Author
  • Semi-Pro I
  • 30 replies
  • Answer
  • May 11, 2024

Adding formatting values solved that issue. 


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