Sunday, September 21, 2008

Cybner / NSquaredSolutions Merger

Cybner has been undergoing a number of changes recently.

I'm happy to anounce that Nsquared Solution and Cybner have agreed to a merger. This is great news, in particular for our existing clients. In particular we now have access to many more resources in order to provide an even higher quality of service.




Sunday, September 7, 2008

Microsoft Dynamics CRM Javascript Access to Form Elements

Here's how to access each control on your forms using Javascript. Using this information you can add very useful functionality to CRM's front end.

There are a couple of ways to do this, you can choose which ever suits your situation best...

Currently displayed entitie's GUID:
        crmForm.ObjectId

To access a control on the form:
    crmForm.all.[attributename]
    // OR
    document.getElementById("[attributename]")

Hide/show attribute(set to visible or invisible):
    //Hide it
    crmForm.all.[attributename].style.display = "none";
    //Show it
    crmForm.all.[attributename].style.display = "inline";

Enable/disable attribute:
   //Disable
   crmForm.all.[attributename].Disabled = true;
   //Enable
   crmForm.all.[attributename].Disabled = false;

Does control/attribute contain any data?
   if (crmForm.all.[attributename] != null)
       //Contains some data

Control's value(this is the current on screen value. ie, may not have been saved yet):
   crmForm.all.[attributename].DataValue
   // OR
   crmForm.all.[attributename].value
   // OR if its a checkbox
   crmForm.all.[attributename].Checked = [true false=""]
   // OR if its a lookup
     //Descriptive name for the selected item
     crmForm.all.[attributename].DataValue.name
     //GUID value of the selected item
     crmForm.all.[attributename].DataValue.id
     //Type of entity selected in the lookup(1=Account, 2=Contact...)
     crmForm.all.[attributename].DataValue.type
     //Descriptive name for the selected entity type
     crmForm.all.[attributename].DataValue.typename


Reference External Javascript file in CRM form events

Some times you may have a great deal of Javascript code to insert into your CRM entity's form events, be it OnLoad, OnSave or OnChange of a control.

It is possible to encapsulate the functionality or procedures into separate JS files and reference them from the form. I often do this and have a list of standard JS files with specific functions as I need them. You can insert the file into your event by ading this block of code.

//Insert JS Functions to perform whatever functionality:

var script = document.createElement("script");

script.language = "javascript";

script.src = "http://crmserver:5555/ISV/JSFiles/CRMControlFunctions.js";

document.getElementsByTagName("head")[0].appendChild(script);


Don't forget to substitute your own server, port and filename. Ensure that it's hosted in a website or virtual directory and reachable from the CRMWeb website application.


Saturday, September 6, 2008

Access MS CRM data through the Web Service via Javascript SDK

So I was madly typing away and badly mixing my languages up as I tried to remember how to access the CRM Web Service using Javascript from the front end when I finally succumbed to calling on a Google search.

I don't usually post something that I've already been able to find on the net, but it took me a while to find this and when I did... Oh man it was like a gift from heaven.

A fantastic post by Jason Hunt at Ascentium:
A Microsoft Dynamics CRM JavaScript SDK
http://www.ascentium.com/blog/crm/Post129.aspx

Tuesday, August 26, 2008

Plugins and Add-ons With Multiple Server CRM Deployment

Recently I had a remarkable amount of trouble with the SDK on a particular CRM deployment. After a spot of poking around I managed to find that this deployment actually consists of 3 servers.
Application Server
Platform Server
Database Server

This configuration seemed to be working fine for some time with plugins hosted on the Application Server, but when I came to write applications using the web services hosted on the Platform Server I received the following error: 0x80044191 Assembly can not be loaded from C:\Program Files\Microsoft Dynamics CRM\server\bin\assembly\MyOrganisation.Plugins.dll. Platform.

Here's the fix:
If plugins are registered, ensure they are deployed with source on database.

If the plugin source MUST be on disk, then it must be stored on the Platform Server. Not the Application Server

Sunday, August 10, 2008

Winforms: Close your form during Load event:

On occasion you may find that you need to open a form and have that form then decide if it needs to remain open.

Closing a form through click of a button is normally not an issue. Its as simple as:

Me.Visible = False
or
Me
.Close

The second method will clear and remove the form from memory. But this means that the form would already have to be visible. Doing this during Form Load will cause an ObjectDisposedException.

But you want your form to close BEFORE it even becomes visible to the user? There are 2 ways to do this.

If your form is a dialog:
VB: Me.DialogResult = DialogResult.Cancel
C#: this.DialogResult = DialogResult.Cancel;

Otherwise, place this code in the form load event:
VB: Me.BeginInvoke(New MethodInvoker(AddressOf Me.Close))
C#: this.BeginInvoke(new MethodInvoker(this.Close));

Thursday, July 17, 2008

Display Database Image in SSRS from Northwind demo database.


If you’re reading this, then like me you probably fiddled around for an hour or so, scratched a hole in your head and wondered how such an easy job can be so impossible.

We’re building a SQL Server Reporting Services report that displays an image retrieved from a database field. This is easy.. Assuming that you already know how to build a simple SSRS report, to add a database image, simply select the image field into your dataset, drop an image control onto your report and select its “value” to the value of the image field from your dataset.

If you try this using the SQL Server version of Northwind, you’re sure to have trouble. The image will not display and you’ll get a little red cross in the control.


After a quick google search I came across these sites:


Robert Porter speaks the fact that the images saved in the Northwind database are not standard GIF formats, but OEM. Basically caused by converting a MS Access database to SQL Server. There’s also some sample there, but that didn’t work for me. Eventually after a lot more research and help, we have this line of code that converts the OEM GIF image into one readable by SSRS:

System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!Photo.Value), 105))

If you must use Northwind’s original data to display an image on an SSRS report, then use the above line as the image value. Any other SQL Server image field would not need this and will work just fine by simply using the plain field value.