Created a custom ribbon button on case entity and on click of button show a dialog. on completion of dialog refresh entity form.
....
<CustomAction Id="NewCancel" Location="Mscrm.Form.incident.MainTab.Actions.Controls._children">
<CommandUIDefinition>
<Button Id="NewCancelButton" ToolTipTitle="$Resources:Ribbon.Form.incident.MainTab.Actions.Cancel" ToolTipDescription="$Resources:Ribbon.Tooltip.CancelCase" Command=AbandonCase" Sequence="6" Alt="$Resources:Ribbon.Form.incident.MainTab.Actions.Cancel" LabelText="Abandon Case" Image16by16="/_imgs/ribbon/CaseCancel_16.png" Image32by32="/_imgs/ribbon/CancelIncident32.png" TemplateAlias="o1" />
</CommandUIDefinition>
</CustomAction>
....
<CommandDefinition Id="AbandonCase">
<EnableRules>
<EnableRule Id="IsExisting" />
</EnableRules>
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName="AbandonCase" Library="$webresource:new_incident.js" />
</Actions>
</CommandDefinition>
then created a javascript function to show dialog when user click on the custom button
AbandonCase = function () {
window.showModalDialog(OrganisationPath + "/cs/dialog/rundialog.aspx?DialogId=" + AbandonCaseDialog + "&EntityName=incident&ObjectId=" + Xrm.Page.data.entity.getId());
refreshEntityForm();
}
refreshEntityForm = function()
{
//used mainly from ribbon buttons
if (Xrm.Page.data.entity.getIsDirty())
{
// Save form - causes reload
Xrm.Page.data.entity.save();
}
else
{
// Reload form.
window.location.reload(true);
}
}
No comments:
Post a Comment