Friday, 28 February 2014

Import Solution issues in Ms Dynamics CRM - Brain Dump 5

A few weeks back we were trying to import the main solution to our test environment when hit a particularly nasty issue:
Index size error
Updating mre_stamp.mre_name.Length is not valid because this is an indexed attribute and hence cannot have size greater than 900. Original value:200. New value:1000. Existing index is ndx_mre_name with type=6
The obvious solution here is to remove the index and set the field length back to the original value, but if that's not an option then and alternative solution would be to do this:

 1. Unzip the solution zip file.
 2. Open the customizations.xml file in your favourite text editor.
 3. Search for the <attribute PhysicalName="<attributeName>" (use the attribute from the error).
 4. You are looking for something like this (Notice how Length is greater than MaxLength):

 5. Change Length to the same value as MaxLength.
 6. Repeat 3-5 for each field in the SQL index.
 7. Re-Zip the solution file, making sure that the customizations.xml file is in the root folder.
 8. Re-Import Solution.

Thursday, 27 February 2014

Interesting Issues with Join-Path in PowerShell - Brain Dump 4

Another post part of the brain dump series

It turns out that Join-Path can't be used reliably for remote paths, allow me to explain

This will work fine:
PS C:\Users\John> Join-Path "\\SecretMachine\E$\SecretDirectory" "ReallySecretDirectory"
But this won't:
PS C:\Users\John> Join-Path "E:\SecretDirectory" "ReallySecretDirectory"
Join-Path : Cannot find drive. A drive with the name 'e' does not exist.
At line:1 char:10
+ Join-Path <<<<  "e:\SecretDirectory" "ReallySecretDirectory"
    + CategoryInfo          : ObjectNotFound: (e:String) [Join-Path], DriveNotFoundException
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Essentially, Join-Path can handle non-existent UNC paths but if it looks like a local path it expects it to be there.

You can force Join-Path to try to resolve the UNC path but it doesn't look like you can prevent it for local paths.
PS C:\Users\John> Join-Path "\\SecretMachine\F$" "SecretDirectory" -Resolve
Join-Path : Cannot find path '\\SecretMachine\F$\SecretDirectory' because it does not exist.
At line:1 char:10
+ Join-Path <<<<  "\\SecretMachine\F$" "SecretDirectory" -Resolve
    + CategoryInfo          : ObjectNotFound: (\\SecretMachine\F$\SecretDirectory:String) [Join-Path], ItemNotFoundExc
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Wednesday, 26 February 2014

Issues building WiX installer, missing libraries (dlls) - Brain Dump 3

By default Visual Studio will not copy libraries that are installed in the GAC to the output folders, which means that the WiX project that looks for those libraries will fail to build as the libraries will not be there.

I'm not sure if there is a way to override this behaviour in Visual Studio (Copy Always does not seem to make a difference), so ... just remove the libraries from the GAC.

Tuesday, 25 February 2014

Ms Dynamics CRM 2011 integration with Ms Sharepoint 2010 - Brain Dump 2

A few weeks back we went live and had a couple of issue getting the integration between Dynamics CRM 2011 and SharePoint 2010 working:

1. It would say that the list component was not installed.

I tried following this link to no avail and then reading the comments I realized that I had the same issue as the last comment, namely I was using my account rather than the service account to configure the integration and my account does not have any permissions in SP.

2. I also had this issue.

I followed solution (workaround) number IV.

Monday, 24 February 2014

Boxing issues in C# - Brain Dump 1

I'm going through my emails collecting all the interesting stuff that I have accrued over the past year or so, most of it not mine and dumping it here in various posts, I could just keep the pst file but ....

       public void TestMethod1()
            decimal d1 = 20;
            decimal d2 = 20;

            Assert.IsTrue(compare (d1, d2));

        private bool compare (object o1, object o2)
            return o1 == o2;

The test above will fail, should use this instead:

        private bool compare (object o1, object o2)
            return o1.Equals(o2);

Thursday, 13 February 2014

UNEXPECTED: no fault?

Sometimes Microsoft developers are so surprised when their products do work that you get pearls like this:(From trace log of a MS Dynamics CRM 2011 Server and yes I know)

[2014-02-12 07:57:08.825] Process: w3wp |Organization:00000000-0000-0000-0000-000000000000 |Thread: 7 |Category: Platform |User: 00000000-0000-0000-0000-000000000000 |Level: Error |ReqId: f298a0cd-f960-4365-b2c3-b855d2462e1a | ExceptionConverter.ConvertToFault ilOffset = 0x57
>UNEXPECTED: no fault?

Monday, 10 February 2014

Disable Export to Excel from SQL Server Reporting Server 2008/2012

We had an interesting request last week from the business. They were concerned that some users were exporting data to excel and running the business from excel, which was quite surprising as I distinctly remember making sure that nobody had permissions to do so.

Turns out that they were exporting the reports which are old fashioned SSRS reports.

So we decided to disable export to all formats but PDF.

Look for the rsreportserver.config file and change the Render section to this (in essence add Visible="false" to any extension you don't want to allow to be exported):


<Extension Name="XML" Type="Microsoft.ReportingServices.Rendering.DataRenderer.XmlDataReport,Microsoft.ReportingServices.DataRendering" Visible="false"/>

<Extension Name="NULL" Type="Microsoft.ReportingServices.Rendering.NullRenderer.NullReport,Microsoft.ReportingServices.NullRendering" Visible="false"/>

<Extension Name="CSV" Type="Microsoft.ReportingServices.Rendering.DataRenderer.CsvReport,Microsoft.ReportingServices.DataRendering" Visible="false"/>

<Extension Name="ATOM" Type="Microsoft.ReportingServices.Rendering.DataRenderer.AtomDataReport,Microsoft.ReportingServices.DataRendering" Visible="false"/>

<Extension Name="PDF" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.PDFRenderer,Microsoft.ReportingServices.ImageRendering"/>

<Extension Name="RGDI" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.RGDIRenderer,Microsoft.ReportingServices.ImageRendering" Visible="false"/>

<Extension Name="HTML4.0" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.Html40RenderingExtension,Microsoft.ReportingServices.HtmlRendering" Visible="false"/>

<Extension Name="MHTML" Type="Microsoft.ReportingServices.Rendering.HtmlRenderer.MHtmlRenderingExtension,Microsoft.ReportingServices.HtmlRendering" Visible="false"/>

<Extension Name="EXCEL" Type="Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer,Microsoft.ReportingServices.ExcelRendering" Visible="false"/>

<Extension Name="RPL" Type="Microsoft.ReportingServices.Rendering.RPLRendering.RPLRenderer,Microsoft.ReportingServices.RPLRendering" Visible="false" LogAllExecutionRequests="false"/>

<Extension Name="IMAGE" Type="Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRenderer,Microsoft.ReportingServices.ImageRendering" Visible="false"/>

<Extension Name="WORD" Type="Microsoft.ReportingServices.Rendering.WordRenderer.WordDocumentRenderer,Microsoft.ReportingServices.WordRendering" Visible="false"/>


Monday, 3 February 2014

List privileges for security roles in Microsoft Dynamics CRM 2011/2013

So a couple of weeks back I was asked to disable export to excel functionality for all users, unfortunately nobody was sure which roles had the Export To Excel privilege (prvExportToExcel) so I used this query to find out:

select as Role, x.label,p.Name,
case p.accessright -- technically a bit field, but CRM treats as an int
when 1 then 'Read'
when 2 then 'Write'
when 4 then 'Append'
when 16 then 'AppendTo'
when 32 then 'Create'
when 65536 then 'Delete'
when 262144 then 'Share'
when 524288 then 'Assign'
else '?' end as Permission,

case rp.PrivilegeDepthMask -- technically a bit field, but CRM treats as an int
when 1 then 'User'
when 2 then 'BusinessUnit'
when 4 then 'Parent:Child'
when 8 then 'Organisation'
else '?' end as Scope
from role r

left join RolePrivileges rp on r.roleid = rp.roleid
left join Privilege p on rp.privilegeid = p.privilegeid
left join PrivilegeObjectTypeCodes potc on p.privilegeid = potc.privilegeid
left join MetadataSchema.Entity e on potc.objecttypecode = e.objecttypecode
left join (select max(overwritetime) as owt, label, localizedlabelid, objectid, objectcolumnname from 

MetadataSchema.LocalizedLabel group by localizedlabelid, label, objectid, objectcolumnname) as x on e.entityid= x.objectid and x.objectcolumnname = 'LocalizedName'

where like 'prvExportToExcel'
order by, e.logicalname, 3, 4

The left joins are necessary to ensure that the On/Off privileges like Export To Excel are included. This was the result.