Options

[Solved] Nullable decimal

Cem_KaraerCem_Karaer Member Posts: 281
edited 2017-12-13 in NAV Three Tier
Hello,

I have to set a value to the property of a dotnet variable. The property's data type is Nullable<decimal> which is represented as (dotnet) System.Nullable`1.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

I define a variable with that data type but cannot instantiate or set a primitive value (say 2.0, 3.0 ect.) to it.
Please help!
Cem Karaer @ Pargesoft
Dynamics NAV Developer since 2005

Answers

  • Options
    Cem_KaraerCem_Karaer Member Posts: 281
    Hello,

    Unfortunately I found no standard way to accomplish this. So I created a helper class to statically cast any decimal value to Nullable<decimal>. Here is the complete code of the class:
    public static class Helper
        {
            public static Nullable<decimal> ReturnNullableDecimal(decimal Value)
            {
                return (Nullable<decimal>)Value;
            }
        }
    
    The only thing to do is to use that dll in NAV as follows:
    Transfer.ExpectedQuantity := Helper.ReturnNullableDecimal(ProdOrderLine.Quantity); 
    

    So it works like a charm!
    Cem Karaer @ Pargesoft
    Dynamics NAV Developer since 2005
  • Options
    loggerlogger Member Posts: 126
    @Cem_Karaer ,
    Thanks for a solution! Will be helpful!!!
    Let's go!
Sign In or Register to comment.