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)

GetGlobalOptionSetMetadata does not return the very latest result

(0) ShareShare
ReportReport
Posted on by

I'm building a little tool for our CRM Online clients that lets them to change some OptionSet values easily.

I'm using the CRM SDK and, in particular, the following code to retrieve all the possible values of a given OptionSet:

var meta = CrmConnection.ConnectionManager.CrmSvc.GetGlobalOptionSetMetadata(set.LogicalName);
options = meta.Options;

foreach (var opt in options)
{
    setItems.Add(new OptionSetItem { Id = opt.Value.Value, Text = opt.Label.UserLocalizedLabel.Label, ToBeDeleted = false });
}


As you can see I'm using GetGlobalOptionSetMetadata.

Everything works fine and, at the end, the user can publish the changes. The called code is this:

PublishXmlRequest pubRequest = new PublishXmlRequest { ParameterXml = String.Format("<importexportxml><optionsets><optionset>{0}</optionset></optionsets></importexportxml>", currentOptionSet.LogicalName) };
CrmConnection.ConnectionManager.CrmSvc.ExecuteCrmOrganizationRequest(pubRequest);


 After the publishing, I want to refresh the view in order to see the very latest state of the OptionSet. So I re-call the first piece of code. The problem, here, is that GetGlobalOptionSetMetadata does not return the latest version of the OptionSet, but the previous one.

The only thing to see the changes is to quit the program and reconnect to the CRM. I'm wondering if there is something "cached" that is not released. Any hint? Thanks!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Surmeet Singh Profile Picture
    3,075 on at

    Hi,

    This is because the current program runs crm svc tool at the start of the application and get the latest optionset from CRM where as when you call the above again it doesnot get the new optionsets.

    If you were using latebound then it would not be an issue, so what you can do here is to get the method that is being called at the starting of the application and gets the optionset and call that method or you can restart the application as well.

  • ScottDurow Profile Picture
    21 on at

    This is because the connection manager will cache metadata calls by default. Try using named connection pools or changing the connection instance mode - see msdn.microsoft.com/.../83124000-0f48-4477-a250-5fab0854aace

  • Community Member Profile Picture
    on at

    Thanks Scott. This sounds interesting but I'm wondering how can I implement it if I'm using the "XRM tooling common login" to create and maintain a CrmConnection: msdn.microsoft.com/.../dn689071.aspx

  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Sorry - missed you were using Xrm Tooling. You can use the ResetLocalMetadataCache method on the CrmSvc.

    Hope this helps,

    Scott

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