Don't use eval to parse JSON data
May 20, 2014
The code is executed! This could perhaps be used to return malformed instructions instead of JSON and do something malicious to the client. However, try this:
Notice that it just throws a parsing error, but of course for actual JSON it still produces the correct object.
Error adding dynamic values to email templates in Dynamics CRM Workflows
May 01, 2014
This morning I was setting up a new workflow process for sending an email to some users and came across a weird bug. When editing the body of an email, everything was fine until I needed to add a dynamic value from the entity to the email’s body, and then as soon as I tried to save, this:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: System.Xml.XmlException: Microsoft Dynamics CRM has experienced an error.
Dynamics CRM - Replacing old CRM 4 API references with regular expressions
Feb 19, 2014
When upgrading Dynamics CRM 2011 to the most recent set of updates, it turns out that CRM 4 API stuff was no longer supported, even though the Microsoft code validation tool said that it should all work in IE! >:-[
So I needed to quickly replace loads of old CRM 4 API references, such as
crmForm.all.some_field.DataValue = 1;
with the newer CRM 2011 API, which in this example would look like:
Altering User-Defined Sharing Permissions for Dynamics CRM Charts Directly in the Database
Jan 23, 2014
Today I received an email from a user experiencing difficulty editing charts that had been shared with them by another user, who had forgotten to check the “Write” permission. Unfortunately this person was away for the day, and for some reason CRM doesn’t have a neat admin tool for managing individual user-specified sharing settings for charts and such. So I had little choice but to dig into the bowels of the database and set the permissions manually.
TSQL - checking for the intersection of two sets of dates
Jan 19, 2014
Double post day!
The same query that had concatenation happening from the previous post also had date range parameters, @StartDate and @EndDate, and needed to only return records (which also had their own start/end date fields) in which the records’ were active during the specified date range. I.e. where the record’s date range intersected with the date range parameters. It confused me for a bit so I’m recording for posterity. As I see it, there are three possible valid cases:
TSQL - Removing a trailing comma from a list of concatenated values
Jan 19, 2014
On a semi-regular basis I’d need to squish a list of comma-delimited values all concatenated together into one field, so I’d use this old snippet:
SELECTLEFT(ConcatValues, LEN(ConcatValues)-1) AS 'TheValues'<o:p></o:p>FROM SomeTable t<o:p></o:p>CROSS APPLY( SELECT t2.SomeField + ’, ‘ AS [text()]<o:p></o:p>FROM SomeTable t2<o:p></o:p>WHERE t.SomeField = t2.SomeField<o:p></o:p>
FOR XML PATH('‘) ) C(ConcatValues)<o:p></o:p>Problem is when the concatenated field has length zero, LEFT gets a -1 length and returns an error:
Msg 537, Level 16, State 5, Line 1<o:p></o:p>Invalid length parameter passed to the LEFT or SUBSTRING function.
Getting an .apk into the Google Play store
Dec 01, 2013
This is mostly for my own reference but I hope someone else can find it useful too :)Disable debugging in your AndroidManifest.xml file by setting android:debuggable="false” in the “application” node.cordova build android –releasejarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore yourkey.keystore app.apk alias_name (assuming you’ve generated a key beforehand using keytool in the JDK bin directory)zipalign -v 4 app-release-unsigned.apk app.apk (obviously replace “app” with your app name)Zipalign must be the last thing that happens!
Stopping Dynamics CRM from auto-creating contacts from tracked Outlook emails
Nov 11, 2013
I encountered an issue today where any time one of several users attempted to track an email in Dynamics CRM (2011) from within their Outlook client it would create contact records in CRM for whoever the email was sent to. I knew this was a setting in CRM somewhere and found it in the settings dialog here:
However I didn’t want to go through all the annoyance of instructing everyone affected to manually alter the setting, so I fixed the problem once-and-for-all (at least until we get more users) by updating it for everyone in the CRM database.
Using WiX to create an event source during install of a .NET framework project
Oct 31, 2013
Edit: so I guess I wasn’t the only one confused with this stuff, as it’s been my most popular post by far! If I’ve helped you out or saved you some time, please let me know in the comments :)
In order for this to work, you have to add references to WixUtilExtension and WixNetFxExtension to your WiX project. Once that’s done, add this inside a <Component> element:
Obviously replace EVENTSOURCEGOESHERE with your event source name.
Using Log4Net to use both event log and a rolling log file
Oct 29, 2013
Here’s the config section, note that the applicationNameproperty in the EventLogAppender needs to be the same as the event source in the windows event log that you want to log to. If the event source doesn’t exist, that appender won’t work. In this particular project I create that during install using WiX (which is covered in another post)