locked
How to edit Status Reason PickList Value on a Custom Entity RRS feed

  • Question

  •  I want to add additional picklist items on a status reason field on a custom entity but the value field is set to ReadOnly. How do I go about updating the value with the one I  want?

    How do I update the Status Reason field through a Pre Update Operation stage through a plugin code?

    Thanks

    Saturday, March 30, 2013 8:08 AM

Answers

  • You should be able to edit the label and the values of the options sets (both new option set and existing option set). If you could not, please provide screen shots or other information to be helped.

    About the status and status reason update (the built in status and reason not the one you created) you have to use:

    SetStateRequest setStateRequest = new SetStateRequest()
                    {
                        EntityMoniker = new EntityReference
                        {
                            Id = A.Id,
                            LogicalName = A.EntityLogicalName,
                        },
                        State = new OptionSetValue(the value of status),
                        Status = new OptionSetValue(the value of reason)
                    };
                    _serviceProxy.Execute(setStateRequest);

    If you want to update the option set (such as custom status or reason) use this:

    OptionSetValue myOptionSet = new OptionSetValue();
    myOptionSet.Value = value; 
    myEntity.Attributes["optionSetAttributeName"] = myOptionSet;


    If the answer helped you, remember to mark it as answer.

    Saturday, March 30, 2013 8:39 AM
    Moderator

All replies

  • Hi,

    Check with the links below,

    http://social.microsoft.com/Forums/en-US/crm/thread/b5710673-b80c-428b-af88-0e435e7d6d23

    http://ms-crm-2011-beta.blogspot.in/2012/05/how-to-update-status-code-and-status.html

    http://crmbusiness.wordpress.com/2012/03/23/crm-2011-setting-a-state-and-status-of-an-entity-using-a-plugin/

    This might be helpful, if so mark this as "Answer" or "Vote as helpful"


    Sindu M


    • Edited by VidhiyaM Saturday, March 30, 2013 8:31 AM
    Saturday, March 30, 2013 8:30 AM
  • You should be able to edit the label and the values of the options sets (both new option set and existing option set). If you could not, please provide screen shots or other information to be helped.

    About the status and status reason update (the built in status and reason not the one you created) you have to use:

    SetStateRequest setStateRequest = new SetStateRequest()
                    {
                        EntityMoniker = new EntityReference
                        {
                            Id = A.Id,
                            LogicalName = A.EntityLogicalName,
                        },
                        State = new OptionSetValue(the value of status),
                        Status = new OptionSetValue(the value of reason)
                    };
                    _serviceProxy.Execute(setStateRequest);

    If you want to update the option set (such as custom status or reason) use this:

    OptionSetValue myOptionSet = new OptionSetValue();
    myOptionSet.Value = value; 
    myEntity.Attributes["optionSetAttributeName"] = myOptionSet;


    If the answer helped you, remember to mark it as answer.

    Saturday, March 30, 2013 8:39 AM
    Moderator
  • I can add a new item under the Status Reason field but cannot edit the value. I need to update the value to 277170000

    Saturday, March 30, 2013 12:12 PM
  • For the status and status reason (built in option sets) you could not change the values.

    If the answer helped you, remember to mark it as answer.

    Saturday, March 30, 2013 12:18 PM
    Moderator
  • I am trying to add new item in the optionset (Picklist).
    Saturday, March 30, 2013 12:19 PM
  • For newly created option sets you could create and edit labels and values. For status and status reason option sets you could add and edit the labels only. You could not edit the values for existing or new options.

    If the answer helped you, remember to mark it as answer.

    Saturday, March 30, 2013 12:25 PM
    Moderator