Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 700159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:27:59+00:00 2026-05-14T03:27:59+00:00

I wrote a plugin for Dynamics 4.0 to change the value of a picklist

  • 0

I wrote a plugin for Dynamics 4.0 to change the value of a picklist when an opportunity entity is reopened. The picklist value is updated correctly, but the form doesn’t show this until the form is closed and reopened.

Here is my plugin:

    public void Execute(IPluginExecutionContext context)
    {
        if (context.InputParameters.Properties.Contains("Target") &&
                context.InputParameters.Properties["Target"] is DynamicEntity)
        {
            ICrmService service = context.CreateCrmService(false);
            DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties["Target"];
            Key key = (Key)entity.Properties["opportunityid"];

            DynamicEntity DynamicOpportunity = GetOpportunity(service, key.Value);
            Picklist StageCodePicklist = (Picklist)DynamicOpportunity.Properties["salesstagecode"];
            StageCodePicklist.IsNull = false;
            StageCodePicklist.IsNullSpecified = false;
            StageCodePicklist.name = "Advocating - Advanced (90%)";
            StageCodePicklist.Value = 200004;

            DynamicOpportunity.Properties["salesstagecode"] = StageCodePicklist;
            service.Update(DynamicOpportunity);
        }
    }

The information I assign to properties on StageCodePicklist was derived from the following query run against the database:

select * from stringmap where attributename='salesstagecode'

To reiterate, I reopen an opportunity and the salesstagecode is correctly updated, but the form displays the old value. Closing the form and reopening it for the same opportunity shows that the new value was indeed in the database.

I almost wonder if this is a bug with CRM – surely the form should display the updated value without having to close and reopen the form. But that aside, is there anything I can do to accommodate so users don’t have to do this to see the updated value rather than the old value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:27:59+00:00Added an answer on May 14, 2026 at 3:27 am

    Regardless of if you register this in a pre-stage or a post-stage it should be reflected when the form reloads. The only thing that would delay the update is if you registered your plugin to run asynchronously, in which case it runs in the background Async Service.

    Which mode are you registering the plugin step as? (1=Asynchronous, 0=Synchronous).

    In addition, if you register your plugin to run in the pre-stage and synchronously you can get rid of a lot of the code by just updating the target input parameter.

    public void Execute(IPluginExecutionContext context)
    {
        if (context.InputParameters.Properties.Contains("Target") &&
            context.InputParameters.Properties["Target"] is DynamicEntity)
        {
            DynamicEntity opp = (DynamicEntity)context.InputParameters["Target"];
            opp["salesstagecode"] = new Picklist(200004);
        }
    }
    

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Dynamics CRM 4.0 installed and wrote a plugin, registered it, and setup
In Microsoft Dynamics CRM 2011, I wrote one plug-in in C# for Account entity
I wrote a new eclipse view plugin and when you select Window -> Show
I wrote a plugin for jQuery but now my users are asking for the
I wrote a jQuery lightbox plugin, but I cannot figure out why the wrapper
I need to write a plugin for Dynamics CRM 4.0 that executes when a
I wrote a jQuery plugin that binds to 8 elements on a page, and
I wrote a jQuery plugin, which set the DOM size to the window size.
I wrote a custom wordpress plugin that is shown in the left menu bar
I'm working with the jQuery Validation plugin and I wrote the following code which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.