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


































Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

7 thoughts on “Calling On Demand Workflow through a Button in Ribbon (launchOnDemandWorkflow) in CRM 2011”

  1. Pingback: Anonymous
  2. (“/_grid/cmds/dlg_runworkflow.aspx”)
    It is the form that asks the confirmation of the workflow. This is the location on the server of the form aspx file that is the dialog.


  3. The reason it didn’t work with the url is because there are “{” and “}” around your guid which must be removed.


Share your thoughts

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s