Monday 23 September 2013

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

l 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

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
Final Output

No comments:

Post a Comment