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.

http://inogic.blogspot.com/2009/06/call-workflow-from-isv-button.html

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

http://servername/orgname/_grid/cmds/dlg_runworkflow.aspx?


iObjType=10004

&iTotal=1

&sIds=%7b4BEBDCAF-8F66-E011-A475-00155D045711%7d%3b

&wfId=%7bF0ED25C7-5129-4297-8515-69DFFA0739FF%7d


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}”;

window.open(url);

}

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

http://axforum.info/forums/showthread.php?t=29333

Final Output

The ribbondiffxml used is following

    <RibbonDiffXml>

            <CustomActions>

                <CustomAction

                Id=CA_MyFirstButton

                Location=Mscrm.Form.new_rip.MainTab.Workflow.Controls._children

                Sequence=31>

                    <CommandUIDefinition>

                        <Button

                        Id=B_MyFirstButton

                        Command=Cmd_JavaScript

                        LabelText=Invite Service Member

                        ToolTipTitle=Invite User

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

                        TemplateAlias=o1

                        Image16by16=/_imgs/ribbon/startdialog_16.png

                        Image32by32=/_imgs/ribbon/startdialog_32.png></Button>

                    </CommandUIDefinition>

                </CustomAction>

            </CustomActions>

            <Templates>

                <RibbonTemplates

                Id=Mscrm.Templates/>

            </Templates>

            <CommandDefinitions>

                <CommandDefinition
Id=Cmd_JavaScript>

                    <EnableRules>

                        <EnableRule
Id=Mscrm.Enabled></EnableRule>

                    </EnableRules>

                    <DisplayRules></DisplayRules>

                    <Actions>

                        <JavaScriptFunction

                            Library=$webresource:new_InOut

                            FunctionName=CallOnDemandWF

                    >

                        </JavaScriptFunction>

                    </Actions>

                </CommandDefinition>

            </CommandDefinitions>

            <RuleDefinitions>

                <TabDisplayRules/>

                <DisplayRules/>

                <EnableRules/>

            </RuleDefinitions>

            <LocLabels/>

        </RibbonDiffXml>

Bye.

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. The reason it didn’t work with the url is because there are “{” and “}” around your guid which must be removed.

    Like

  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.

    Like

  3. Pingback: Anonymous

Please share your thoughts

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

The CRM Ninja

Thoughts & musings from a Dynamics 365 Ninja!

CRM for You and Me

Customer Relationship Mgt App for the Professional

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog

Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Knowhere365

Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue MVP

A Microsoft Business Applications MVP

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

Two Bite Tips

Valuable Tips To Grow Your Business

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.

CRM Keeper

Dynamics 365 Customer Engagement, CRM, Microsoft CRM, Dynamics CRM

EVOLVED365

Step into the world of a Dynamics 365 Consultant

Dianamics PCF Lady

Diana & Dynamics 365 & Power Platform

Sara Lagerquist

No Code Customization Concepts

innovativeaj

developer, designer, writer, fun loving, patriotic, humble and a sweet person inside out :) love and respect people who have a great sense of humor.

Temmy Wahyu Raharjo

Dreaming to be a clean coder and TDD minded programmer.

Transform 365

We blog about problems we face and code we write to help others

%d bloggers like this: