Invert sign on decimal field with AutoFormatExpr property

emerikspemeriksp Member Posts: 10
Hi,
I want to create a list page showing purchase lines (T39) from orders and return orders.
If the record's Document Type=Order, the field Quantity should be shown as default, but if the Document Type=Return Order, the field Quantity should be shown with inverted sign (e.g. Quantity=4 would be shown as -4 and vice-versa). I don't want to change the data, and I don't want to calculate the data on the page because this would prevent the users from sorting and filtering the data afterwards.
So, I was wondering, if I can acheive this by the use of the AutoFormatExpr-property on the page column.

I have tried to create a AutoFormatExprText string variable and set it to '-<Standard Format,0>' in the OnAfterGetRecord, if Document Type=Return Order and Quantity > 0, and then set the AutoFormatExpr=AutoFormatExprText on the column Quantity (AutoFormatType=10). That didn't work.

I am coding in NAV 2017. Any suggestions?

BR Emerik

Answers

  • JuhlJuhl Member Posts: 724
    Use .NET
    Create a System.Decimal variable. DOTNET type in mscorlib, call it SystemDecimal.
    Call the Negate function with your value as parameter.
    NegativeDecimal := SystemDecimal.Negate(PositiveDecimal);
    Or use it directly in SourceExp.
    Follow me on my blog juhl.blog
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Does assigning a .NET variable in SourceExp allows for filtering or sorting on that field?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • JuhlJuhl Member Posts: 724
    Yes as long as it mappes to a Nav type i see no problem. Havent tested this scenario.
    Otherwise assign the returnvalue to a decimal variable.
    Follow me on my blog juhl.blog
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Hmm, and assigning a variable to SourceExpr of a field on a Page allows for filtering or sorting on that field?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • JuhlJuhl Member Posts: 724
    Oh your right.
    I always replace the value in the table :-)

    But the function work.
    Follow me on my blog juhl.blog
Sign In or Register to comment.