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)

OptionSetValue not set to an instance of an object

(0) ShareShare
ReportReport
Posted on by

Hello,

I am creating a plugin for Dynamics 365 using c#, however, I am facing issues using InArgument<OptionSetValue> I am referencing the correct entity and the correct field. 5238.unknown.png

I get the value of the OptionSet as follows unknown-_2800_1_2900_.png

However, when I try to trigger any method on the OptionSetOne

I always trigger an error in Dynamics 365.

This is my form data and the UI of the Dynamics 365 obviously recognizes that there is a OptionSet.

unknown-_2800_2_2900_.png

*This post is locked for comments

I have the same question (0)
  • Charles Abi Khirs Profile Picture
    3,569 on at

    Hello,

    Make sure that the name of the entity new_getsettings is correct and the field post_settings exists in this entity.

  • Community Member Profile Picture
    on at

    The names match precisely. Something else must be the reason why I am getting a null.

  • Community Member Profile Picture
    on at

    I'd like to add that I set the values in the workflow as shown but I get a null instead of the OptionSetValue in the c# code.

  • Charles Abi Khirs Profile Picture
    3,569 on at

    Did you try

    OptionSetValue optionSet = OptionSetOne.Get<OptionSetValue>(executingContext).Value;

  • Community Member Profile Picture
    on at

    It still says that the object is null

  • Charles Abi Khirs Profile Picture
    3,569 on at

    Did you try with other values for the optionset1 input parameter?

    Other optionsets input parameters are working fine?

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi Hristo

    Your error message clearly states that your OptionSetOne.Get.. returns null so there is no optionSet value being set for the input parameter.

    If you are entity and field names are correct, its where you are setting the value to the parameter in the workflow the issue is.

    Could you try and set a default value and see if the object is still null

    OptionSetValue

    [Input("OptionSet1")]

    [AttributeTarget("new_getsettings", "post_settings")]

    [Default("3")] // Plesae set your default value here

    public InArgument<OptionSetValue> OptionSetOne { get; set; }

    I have one question though, how come your entity name has new_ prefix but your option set prefix is post_ , are you directly using the global option set name, you have to use the entity field name. make sure you use the entity attribute name.

     

    Let us know if you still get the error 

     

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Hristo,

    Do remember that if you make any changes to input/ output parameter after registering the assembly then the changes will not take place unless you unregister the assembly and then register it again. I would suggest to unregister the assembly and then register it again and see if it works.

    Hope this helps.

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Hi Hristo,

    Could you please that you are passing default value in parameter  ?

    Please do refer following url for reference :

    anythingcrm.blogspot.com/.../crm-2011-workflow-activity-parameter.html

  • Suggested answer
    Sreevalli Profile Picture
    3,256 on at

    Hi,

    Add Context.depth check

    if (context.Depth > 1)

        return;

    also check if any other triggers, if you believe that the entity and attribute names are correct.

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