While doing ribbon customization today I found an interesting issue with how the new Xrm.Page model introducted in CRM 2011.
I have a ribbon button which simply fires a javascript function:
function lookup_form() {
alert(Xrm.Page.getAttribute("dc_openform").getValue());
alert(crmForm.all.dc_openform.DataValue);
}
I would type a value into my dc_openform field, and click the ribbon button. The first alert would show what was *previously* in the field, while the second alert showed what is *currently* in the field. If I clicked off the field then click the button again, the values match up.
Thus, it appears the the Xrm.Page model is only updated onChange, and that onChange is not fired between typing into a field and clicking the Ribbon button.
Saturday, April 16, 2011
Thursday, April 7, 2011
Odd Currency Symbols returned from FetchXML
While working with CRM2011 FetchXML, I came across a nasty issue when retrieving a currency field. I have done this successfully many times before, but for some reason this time I was getting multiple currency symbols in my raw XML result, ie:
$‎5,000
instead of the desired:
$5,000
Adding transactioncurrencyid to the fetch did not help, and replacing "$‎" with "$" directly also did not work. However, after toying about with the string in unicode for a bit, I came up with:
value = Regex.Replace(value, "\u200e", "");
This properly removed the funky symbols, leaving me with "$5,000". Likely something under the hood is causing an issue elsewhere, but this is a great workaround if you just need to get a properly formatted currency field without hacking deeper into the CRM platform.
$‎5,000
instead of the desired:
$5,000
Adding transactioncurrencyid to the fetch did not help, and replacing "$‎" with "$" directly also did not work. However, after toying about with the string in unicode for a bit, I came up with:
value = Regex.Replace(value, "\u200e", "");
This properly removed the funky symbols, leaving me with "$5,000". Likely something under the hood is causing an issue elsewhere, but this is a great workaround if you just need to get a properly formatted currency field without hacking deeper into the CRM platform.
Friday, April 1, 2011
No Calendar when Enabling DateTime fields via Javascript
I ran into an annoying problem today. I was enabling and disabling a DateTime field via Javascript via the following code:
Xrm.Page.getControl("new_datetimefield").setDisabled(true/false);
However, even when enabled, the calendar button did not function and I couldn't put any dates in the text box.
It turns out that this is a bug in CRM2011 - The fix is to ensure that the DateTime field is enabled by default on the form, then disable or enable via Javascript. If it is initially disabled, it will not be properly editable even when enabled via Javascript.
Xrm.Page.getControl("new_datetimefield").setDisabled(true/false);
However, even when enabled, the calendar button did not function and I couldn't put any dates in the text box.
It turns out that this is a bug in CRM2011 - The fix is to ensure that the DateTime field is enabled by default on the form, then disable or enable via Javascript. If it is initially disabled, it will not be properly editable even when enabled via Javascript.
Tuesday, March 8, 2011
Assembly must be registered in isolation
While attempting to register plug-ins on our new CRM2011 box today, I ran into this error message, "Assembly must be registered in isolation." This was driving me nuts -- I could register in the Sandbox without issue, but I needed access to system Mutexes and data logs on the hard drive which are unavailable in Sandbox.
This ended up being a simple fix -- I needed to add my user to the "Deployment Managers" group, in addition to the System Administrator group he was already in. With that done, registering went off without a hitch!
This ended up being a simple fix -- I needed to add my user to the "Deployment Managers" group, in addition to the System Administrator group he was already in. With that done, registering went off without a hitch!
Monday, February 28, 2011
Unable to Select Header when Modifying View
While working earlier today on a client server (Windows Server 2008 R2) in CRM4, I came across an incredibly annoying issue: I was unable to select a header in a view in order to move or delete it. It turns out, the client machine had IE Enhanced Security Configuration enabled, which was causing this very peculiar bug!
To disable IE ESC:
1) Open up the Server Manager.
2) On the bottom right of the Manager, under Security Information, click "Configure IE ESC".
3) Set both options to Off.
Now that these are disabled, you should be able to select your column headers!
To disable IE ESC:
1) Open up the Server Manager.
2) On the bottom right of the Manager, under Security Information, click "Configure IE ESC".
3) Set both options to Off.
Now that these are disabled, you should be able to select your column headers!
Friday, February 25, 2011
Error Accessing CRM 2011 Online Plugin-Registration Tool
This can be a frustrating error when trying to access CRM 2011 Online via the plugin registration tool:
Luckily, there is a pretty simple fix. Open up your %userprofile%\LiveDeviceID\ folder, and delete LiveDevice.xml (back it up in case something goes wrong!).
Restart the plugin registration tool, and it should now connect properly!
Unhandled Exception: System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.
Server stack trace:
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout)
at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustContract.Issue(Message message)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustChannel.Issue(RequestSecurityToken rst, RequestSecurityTokenResponse& rstr)
at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateLiveIdInternal(ClientCredentials clientCredentials, SecurityTokenResponse deviceToken, String keyType)
at Microsoft.Xrm.Sdk.Client.ServiceConfiguration`1.AuthenticateDevice(ClientCredentials clientCredentials)
at Microsoft.Xrm.Sdk.Client.DiscoveryServiceConfiguration.AuthenticateDevice(ClientCredentials clientCredentials)
at PluginRegistrationTool.CrmConnection.get_DiscoveryService() in C:\Projects\CRM 2011 SDK\sdk\tools\pluginregistration\CrmConnection.cs:line 272
at PluginRegistrationTool.CrmConnection.RetrieveOrganizations() in C:\Projects\CRM 2011 SDK\sdk\tools\pluginregistration\CrmConnection.cs:line 367
at PluginRegistrationTool.ConnectionsForm.OpenConnection(CrmConnection con) in C:\Projects\CRM 2011 SDK\sdk\tools\pluginregistration\ConnectionsForm.cs:line 940
Inner Exception: System.ServiceModel.FaultException: Invalid RequestLuckily, there is a pretty simple fix. Open up your %userprofile%\LiveDeviceID\ folder, and delete LiveDevice.xml (back it up in case something goes wrong!).
Restart the plugin registration tool, and it should now connect properly!
Monday, January 24, 2011
Javascript & Read-Only Picklists
So you've got this great bit of Javascript that changes a read-only picklist field. Great! The only problem is, when the code fires on an update form, the picklist that you set doesn't get saved! It'll work on create, so whats the deal?
What you need to do is go back into your Javascript and enable the "ForceSubmit" attribute of the picklist. For example (from CRM 2011, changing one picklist based on the value of another picklist onchange):
function CheckType() {
if(crmForm.all.new_type.DataValue == 100000001) {
crmForm.all.new_readonlypicklist.DataValue = 100000001;
crmForm.all.new_readonlypicklist.ForceSubmit = true;
}
}
Your picklist field should now update and save properly!
What you need to do is go back into your Javascript and enable the "ForceSubmit" attribute of the picklist. For example (from CRM 2011, changing one picklist based on the value of another picklist onchange):
function CheckType() {
if(crmForm.all.new_type.DataValue == 100000001) {
crmForm.all.new_readonlypicklist.DataValue = 100000001;
crmForm.all.new_readonlypicklist.ForceSubmit = true;
}
}
Your picklist field should now update and save properly!
Subscribe to:
Posts (Atom)