Calling On Demand Workflow through a Button in Ribbon (launchOnDemandWorkflow) in CRM 2011

I had to call an on demand workflow through a custom button click inside the ribbon. I thought of using launchOnDemandWorkflow function.

But couldn’t really find a way of calling that function.

So thought of calling it through its url, which would be something like this






function CallOnDemandWorkflow() {

var recordID = crmForm.ObjectId;

var url = http://server/org/_grid/cmds/dlg_runworkflow.aspx?iObjType=10004&iTotal=1&sIds={“ + recordID + “}&wfId={F0ED25C7-5129-4297-8515-69DFFA0739FF}”;;


However I keep getting some JavaScript Error.

Finally found out the correct way of doing so.

function CallOnDemandWF() {

var a = new Array(crmFormSubmit.crmFormSubmitId.value);

var sIds = crmFormSubmit.crmFormSubmitId.value+“;”;

var sEntityTypeCode = “10004”; //Replace this with your entity type code

var sWorkflowId = “{F0ED25C7-5129-4297-8515-69DFFA0739FF}”; //Replace this with your actual workflow ID

var iWindowPosX = 500; //Modal dialog position X

var iWindowPosY = 200; //Modal dialog position Y

var oResult = openStdDlg(prependOrgName(“/_grid/cmds/dlg_runworkflow.aspx”)+“?iObjType=” + CrmEncodeDecode.CrmUrlEncode(sEntityTypeCode) + “&iTotal=” +

CrmEncodeDecode.CrmUrlEncode(a.length) + “&wfId=” + CrmEncodeDecode.CrmUrlEncode(sWorkflowId)+ “&sIds=” + CrmEncodeDecode.CrmUrlEncode(sIds) , a, iWindowPosX, iWindowPosY);


Check out the thread

Final Output

The ribbondiffxml used is following











                        LabelText=Invite Service Member

                        ToolTipTitle=Invite User

                        ToolTipDescription=Use this workflow to invite Service Member to the portal


































Initializing and setting DefaultCrendentials for OrganizationService in CRM 2011

I created a simple windows application just to see how to make use of IOrganizationService within CRM 2011.

Here we need to add references to the following dlls

  1. Microsoft.Xrm.Sdk.
  2. System.ServiceModel.
  3. System.Runtime.Serialization.

This is the sample code

Uri organizationUri = new Uri("http://crmservername/orgname/XRMServices/2011/Organization.svc");
Uri homeRealmUri = null;
ClientCredentials credentials = new ClientCredentials();
// set default credentials for OrganizationService
credentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;
// or
credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null);
IOrganizationService _service = (IOrganizationService)orgProxy;
    Entity myAccount = new Entity("account");
    myAccount["name"] = "Test Account";
catch (Exception ex)

Dependent Picklist (OptionSet) in CRM 2011


Today i was just trying to check if the dependent picklist code generated using Microsoft Dynamics CRM Demonstartion Tools for CRM 4.0 will work for CRM 2011 or not.

So i downloaded the tool

I was able to connect CRM 2011 using that tool. Then i generated the code using the tool.

I tried using that code inside CRM 2011 and it worked properly.

Only thing we need to do is to wrap the entire onload code generated by tool inside a function and call that function on the onload of the form and same thing for the onchange code.


“An Error Has Occurred” while opening form in CRM 2011.

I was getting the following error while opening form of one of the entity (new_client) after upgrading the CRM server from beta version to RTM.

and inside application log

Exception information:

Exception type: NullReferenceException

Exception message: Object reference not set to an instance of an object.

at Microsoft.Crm.Application.Controls.AppNavigationBar.CreateOrderedAreas(NavPaneItems navPaneItems)

at Microsoft.Crm.Application.Controls.AppNavigationBar.ConfigureControl()

at Microsoft.Crm.Application.Components.UI.CrmUIControlBase.ConfigureControlInternal()

at System.Web.UI.Control.PreRenderRecursiveInternal()

at System.Web.UI.Control.PreRenderRecursiveInternal()

at System.Web.UI.Control.PreRenderRecursiveInternal()

at System.Web.UI.Control.PreRenderRecursiveInternal()

at System.Web.UI.Control.PreRenderRecursiveInternal()

at System.Web.UI.Control.PreRenderRecursiveInternal()

at System.Web.UI.Control.PreRenderRecursiveInternal()

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The issue was we had commented some of the NavBarArea tag within the FormXml of the Entity.

<!–<NavBarArea Id=”Service”><Titles><Title LCID=”1033″ Text=”Service”/></Titles></NavBarArea><NavBarArea Id=”Marketing”><Titles><Title LCID=”1033″ Text=”Marketing”/></Titles></NavBarArea>–>

Uncommenting it and importing it again resolved the issue.

This was not creating issue for the beta version, however it seems that it won’t allow us to do that in the RC or RTM version.

The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2711.

I was getting the above error while uninstalling CRM 2011 Server beta.

Uninstalling Microsoft Dynamics CRM 2011 for Microsoft Office Outlook before uninstalling Server resolved the issue.

Showing a custom aspx deployed in ISV in IFrame of CRM form (CRM 2011)

We had one of our web application deployed inside ISV folder in CRM 2011. We were showing one of the aspx pages in it inside an IFrame of a form.

First we specified the relative url like this for URL field in CRM form


However on form we were getting page not found error.

Using developer tools, we found out that it was taking the url (src) for the iframe as


It was appending the organization name to it.

In CRM 4 this wasn’t the case.

Then we gave the absolute url for URL field in IFrame.


However this time also we got page not found error. The url that it was using was

http://servername/contoso/isv/myWebApplication/Default.aspx i.e. again appending orgname to it.

The way we got it working was to define the src of the Iframe dynamically in the form onload event’s JavaScript.

function IframeSrc(){

crmForm.all.IFRAME_Map.src=”/ISV/ myWebApplication / Default.aspx”;


Hope it helps !

%d bloggers like this: