Converting .NET (DotNet) System.Decimal to c/al Decimal

Chris2402Chris2402 Member Posts: 2
I have a property on a .NET Object that is of type decimal? (Nullable decimal), which i need as an entry in a table Field (decimal).
I created a variable of type System.Decimal to make the code more explisitt - and according to MSDN there is a implisitt mapping between System.Decimal (.NET) to Decimal (C/AL).
    Decimal := Invoice.Tax;
    IF NOT ISNULL(Decimal) THEN
      "Harvest Invoice Header".Tax := Decimal;


But this gives me the following error:
"Type Conversion is not possible because 1 of the operators contains an invalid type.

Decimal := DotNet"

Is there anyways around this?

Answers

  • Wisa123Wisa123 Member Posts: 308
    edited 2017-01-04
    Try using a Variant. Check the posts by @andrewt
    http://forum.mibuso.com/discussion/62097/nav2013r2-net-webservice-decimals-all-null

    I also encountered this problem a few days ago trying to do some WebService Communication with an early build of 2013R2. Depending on how/where you want to use your nullables, you got to look for a workaround if the link above doesn't help you.
    Austrian NAV/BC Dev
  • okioki Member Posts: 46
    How is your .Net Variable "Decimal" declared?
    I suppose you can use
    "Harvest Invoice Header".Tax := Decimal.Value;

    Hope it helps
    Oki
Sign In or Register to comment.