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!