Sep 26, 2012

Execute a Dialog in form events

Dialogs are initially introduced to use through a given button and select one from the list in the resulted pop-up page. I think it could be used to get executed in different form events. Typically, when change a drop down, system can prompt a Dialog to get some responses related to that action which will do some other operation.

We can execute Dialog from any action. Check the method I use for this;

function launchDialog(_dID, _eName, _rId)

var sUri = Mscrm.CrmUri.create('/cs/dialog/rundialog.aspx'); + '?DialogId=' + _dID + '&EntityName=' + _eName + '&ObjectId=' + _rId, null, 'width=615,height=480,resizable=1,status=1,scrollbars=1');


We need to pass three parameters here. Check the calling part as below;

    var _workflowid = 'f2057c43-0670-4384-93d4-ac6147611c98';
    var _onjecttype = 'new_insurance';
    var _instanceid = crmForm.ObjectId;

    launchModelDialog(_workflowid, _onjecttype, _instanceid);

Though other two parameters are familiar, not workflow id. Ok now this is the way of obtaining it;
- Import the customization of the Dialog
- Open the customization file
- Search for word “Workflow”

You will see this kind of section which gives you the workflow id.

<Workflow WorkflowId="{f2057c43-0670-4384-93d4-ac6147611c98}" Name="Insurance Renewal">


1) Be careful when deploying the since Guid of the workflow is different in different environments. So you have to change it accordingly.

2) One could feel like using a Dialog for an operation which has nothing to do with individual record (record instance). In such occasions, though it is logical to think not to pass any value for instance id, it is a must to pass one. If you don’t pass, Dialog will not pop-up as expected, but below message will be thrown.

Conceptually, Dialog is always defined against an individual record.

No comments:

Post a Comment