Saturday, August 28, 2010

Resizing a CRM form.

I was asked recently to increase the 'y' axis of a CRM form (it's just a html window).  Here's a real easy way to do it:

window.resizeby( 10, 10 ); 

This handy JavaScript function will increase the size of the 'x' and 'y' axis by 10 pixels each.

Hiding a memo field on a CRM form

So I was working away the other day and got a request to hide a memo field on a CRM form.  This is a little bit more complex than just setting the display or visible style attribute.  Here's how it's done:

/*hide memo field*/
document.getElementById("neu_viewstartext_c").style.display = "none";
document.getElementById("neu_viewstartext_d").style.display = "none";
var parentTr =document.getElementById("neu_viewstartext").parentNode.parentNode;
var tr = parentTr.nextSibling;
for(var x = 0; x<3; x++) {/*hide*/
    tr.height = "1";
    tr= tr.nextSibling;/*Assign to sibling*/
for(var x = 0; x<3; x++) {/*show*/
    tr.height = "25";
    tr= tr.nextSibling;/*Assign to sibling*/

Thursday, August 19, 2010

CRM 4.0 and PostRetreivePlugins

Hello Gang,

Ran into an interesting issue today. I had a client that needed to process some data before the form was displayed to the user. So we decided to use the PostRetreive message. We found that the message only returns properties that are on the form. So if you want to examine a property that isn't on the form you're most likely (I haven't tried this yet) going to have to add a pre image to the step.

Happy coding...

Wednesday, August 18, 2010

CRM 4.0 on 64 bit platform.

I was coding away the other day and ran into a real interesting problem. Here's the result of trying to create the CrmService object on a Window 2008r2 server:

System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS0001: Internal compiler error (0xc00000fd)
error CS0003: Out of memory

at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)

This error message initially made me think that there was some permissions issue with the ASPNET user not being able to write to temp. That was not the case. I solved the problem by using sgen to create a .XmlSerializers.dll file. There was some issues with sgen not being able to handle spaces in the path to the key file. So I put everything needed into the same directory and ran sgen. Here's the parameters that I used:

sgen /compiler:/keyfile:keyfile.snk /p [offending].dll

Here's a link to sgen.

Have fun...

Thursday, August 5, 2010

Here's some code (c#) to test for a GUID using a regular expression:

Regex isGuid = new Regex(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", RegexOptions.Compiled);
if (isGuid.IsMatch(owner))
ownerId = new Guid(owner);

Have fun...

Tuesday, August 3, 2010

Some useful regular expressions

Every once in a while I'm asked to do some JavaScript form validation. Here's a handful of regular expressions that I use:

  • SSN: var filter = /^\d{3}-\d{2}-\d{4}$/;
  • TIN: var filter = /^\d{2}-\d{7}$/;
  • Date: var filter = /^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})))?$/; // ($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/;

I'll add to this list as needed...

Happy coding.