web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Check InArgument is Empty for Decimal

(0) ShareShare
ReportReport
Posted on by

Hi,

how can I check if the value of InArgument<Decimal> in a CodeActivity is empty ?
Thanks.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Aiden Kaskela Profile Picture
    19,696 on at

    Hi Donny,

    I don't think there's a way to check if an InArgument is null, especially for primitive types like decimals. The argument will have a value, but if it's not set by the user it would be the default value for the type - 0.0M for decimal.

    Hope this helps! I'd appreciate if you'd mark this as a Verified answer.

    Thanks,

     Aiden

  • Suggested answer
    Royal King Profile Picture
    27,686 on at

    Decimal is a value type. It can never be null.

    If you need to have a nullable type decimal, you can use decimal?  Then you can do myDecimal.HasValue to check whether it has value or not

  • Aiden Kaskela Profile Picture
    19,696 on at

    Hi Chitra,

    I don't think a nullable decimal is allowed as an input attribute, per msdn.microsoft.com/.../gg327984.aspx

    Thanks,

     Aiden

  • Royal King Profile Picture
    27,686 on at

    thats Right CRM does not support nullable types in input/output argument. Thanks

    for correcting it.

  • Verified answer
    Nuno Profile Picture
    2,005 on at

    Hi Donny,

    There is a property  'Expression' for InArgument that can be used to evaluate if the value of an InArgument has been set. This only works for non-nullable datatypes.

    https://msdn.microsoft.com/en-us/library/dd485341(v=vs.110).aspx

    [Input("Value")]
    InArgument<Decimal> decimalValue { get; set; }
    
    protected override void Execute(CodeActivityContext executionContext)
    {
        Decimal value = 0;
        if (decimalValue.Expression != null)
        {
           value = decimalValue.Get<Decimal>(executionContext);
        }
    }


  • Aiden Kaskela Profile Picture
    19,696 on at

    That's awesome Nuno, thanks.

    Aiden

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans