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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

How to solve 'Attribute : .......cannot be set to null' error

(0) ShareShare
ReportReport
Posted on by

I am setting 'statecode' field of entity 'quote' of CRM using script component in ssis as:

if(!Row.activated_IsNull)
        {
            quote.Attributes["statecode"] = Row.activated;
        }
        else
        {
            quote.Attributes["statecode"] = null;
        }

But I am getting following error when I run the it:

pastedimage1650278861287v1.png

What can be the reason for this. Please help!!

Thanks in advance.

I have the same question (0)
  • Guido Preite Profile Picture
    54,084 Moderator on at
    RE: How to solve 'Attribute : .......cannot be set to null' error

    I wrote "is like an optionset", I know that statecode has a specific type to itself but doesn't change the fact that there is a numeric value behind. I don't know how to set it inside the SSIS script you are writing, check how can you set an optionset field inside the ssis script, setting statecode will be nearly the same

  • Community Member Profile Picture
    on at
    RE: How to solve 'Attribute : .......cannot be set to null' error

     Guido Preite 

    In my case the datatype of statecode is 'Status' and not optionset. How do I assign that in SSIS script

  • Guido Preite Profile Picture
    54,084 Moderator on at
    RE: How to solve 'Attribute : .......cannot be set to null' error

    statecode is like an optionset, you need to set it as an optionset (so with a numeric value behind), not as a string, and "Draft" is definitely not a valid state. Check the statecode from the metadata (usually Active is 0 and Inactive is 1) and see how you should set it inside the SSIS script you are writing.

  • Community Member Profile Picture
    on at
    RE: How to solve 'Attribute : .......cannot be set to null' error

    Guido Preite

    I wrote following code but still throws same error:

    if(Row.activated == 1)

           {

               quote.Attributes["statecode"] = "Active";

           }

           else if (Row.activated == 0)

           {

               quote.Attributes["statecode"] = "Draft";

           }

  • Guido Preite Profile Picture
    54,084 Moderator on at
    RE: How to solve 'Attribute : .......cannot be set to null' error

    statecode is for most entities just Active and Inactive, so if the record is not Active (as you are setting in the if condition) then is Inactive

  • Community Member Profile Picture
    on at
    RE: How to solve 'Attribute : .......cannot be set to null' error

    Guido Preite

    Doe that mean I have to hard code it?

  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: How to solve 'Attribute : .......cannot be set to null' error

    the reason is the error message you are receiving, you can't set that field to null, you need to put one of the valid values

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 258

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 179

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 127 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans