Skip to main content
Question

Why does PXFormula change Decimal fields to text


I created a DAC that adds 2 decimal fields within the DAC for a grid. I can’t figure out why after publishing,  the field is a text field and not a decimal field. How do I display it as a decimal field?


    #region EstCostAmt
    [PXDBDecimal()]
    [PXUIField(DisplayName = "Est Cost")]
    public virtual Decimal? EstCostAmt { get; set; }
    public abstract class estCostAmt : PX.Data.BQL.BqlDecimal.Field<estCostAmt> { }
    #endregion

    #region EstFeeAmt
    [PXDBDecimal()]
    [PXUIField(DisplayName = "Est Fee")]
    public virtual Decimal? EstFeeAmt { get; set; }
    public abstract class estFeeAmt : PX.Data.BQL.BqlDecimal.Field<estFeeAmt> { }
    #endregion

    #region EstTotalAmt
    [PXUIField(DisplayName = "Est Total Amt", IsReadOnly = true)]
    [PXFormula(typeof(Add<estCostAmt, estFeeAmt>))]
    public virtual Decimal? EstTotalAmt { get; set; }
    public abstract class  estTotalAmt : PX.Data.BQL.BqlDecimal.Field<estTotalAmt> { }
    #endregion  
  
 

7 replies

Forum|alt.badge.img+6
  • Captain II
  • 569 replies
  • April 4, 2025

If you want to specify the decimals, you can place it within the parameters of the PXDBDecimal attribute:

        [PXDBDecimal(4)]

If you want to provide a default value, you can do it this way:
        [PXDefault(TypeCode.Decimal,"0.0")]

Your last field, EstTotalAmt is missing the field type declaration. It should have either PXDBDecimal or PXDecimal (if it is not saved to the database)


Forum|alt.badge.img

Hello ​@ddiehl00205 

the field is properly defined in the ASPX file by specifying it within PXGridColumn, with the DataField set to match your DAC field: like below

<px:PXGridColumn DataField="EstCostAmt" Type="Decimal" />
<px:PXNumberEdit ID="edEstCostAmt" runat="server" DataField="EstCostAmt" />


 


  • Author
  • Freshman I
  • 3 replies
  • April 4, 2025

Thanks Django. PXDecimal worked. I was using PXDBDecimal and it kept going to the database for the field that didn’t exist, so I pulled it out. Now that it is being displayed as a decimal, I noticed that when I make a change to either the Cost or Fee in the UI Grid, it doesn’t change the Total amount until I save it. As a text it changes the total amount as soon as I make any changes to that field. I did set the layout property to true for CommitChanges. Do you have any idea why it behaves differently between text and decimal

 

 

 


darylbowman
Captain II
Forum|alt.badge.img+13
ddiehl00205 wrote:

PXDecimal worked

If you’re saying that you’ve changed PXDBDecimal to PXDecimal, you’ve now told Acumatica the field is ‘virtual’ and shouldn’t be saved. You’re probably going to want to change it back.

Occasionally Acumatica needs some help refreshing things by restarting the application from Apply Updates. That could have been the original problem.


  • Author
  • Freshman I
  • 3 replies
  • April 4, 2025

Removing the PXDBDecimal caused my original issue where the total amt field was showing up as text. During that particular testing I noticed that as soon as I changed the cost or fee in the UI, the total amt  would be updated. I did not know the difference between PXDBDecimal and PXDecimal until Django pointed that out to me and after inserting the PXDecimal , the text field now shows up as a decimal. But, the behavior changed for the total amt. After updating the cost or fee, I have to save the record before the total amt is updated. I think that the user would prefer to see the total amt be updated before they save the record.


darylbowman
Captain II
Forum|alt.badge.img+13
ddiehl00205 wrote:

...I did set the layout property to true for CommitChanges...

I see CommitChanges = true for EstTotalAmt. This isn’t actually necessary most likely. What would be necessary is CommitChanges = true for EstCostAmt and EstFeeAmt, since these are the components that make up the EstTotalAmt. You need to allow the server to recalculate the EstTotalAmt when either changes.


  • Author
  • Freshman I
  • 3 replies
  • April 4, 2025

Awesome, that makes logical sense and works. Thanks


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