Wednesday, October 26, 2011

Open CRM Process Dialog using Javascript

Here, one of important thing is Process Dialog Id doesn't change if you export the solution to any environment.

Step 1
Include the below function to onLoad in the form

function RunMembershipPaidProcessDialog()
{
    //Set the process dialog Id below
    var dialogID = "%7b706886CB-FFAB-4ECC-967E-B457CBE8C2C1%7d";
 
    //Set the entity logical name
    var entityName = Xrm.Page.data.entity.getEntityName();

    //Get the current record Id
    var recordId = Xrm.Page.data.entity.getId();
    
    //Set the Process Dialog width & height
    var width = "550";
    var height = "450";
 
    LoadProcessDialog(dialogID, entityName, recordId, width, height);
}
Step 2 Create a Common Javascript resource file (if you havn't create yet) so you can add all the common javascript function in this web resource. and add the below function
function LoadProcessDialog(dialogID, entityName, recordId, width, height)
{
    var context = Xrm.Page.context;
    var sUrl = window.parent.location.href;
    sUrl = sUrl.substring(0, sUrl.indexOf('/main.aspx'));

    var fullUrl = sUrl + "/cs/dialog/rundialog.aspx?DialogId=" + dialogID + "&EntityName=" + entityName + "&ObjectId=" + recordId;

    ShowPopUpWindow(fullUrl, "newWindow", width, height);
}


function ShowPopUpWindow(url, title, w, h)
{
    var left = (screen.width/2)-(w/2);
    var top = (screen.height/2)-(h/2);
    var targetWin = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);    
}

1 comment:

  1. Merkur 37C Safety Razor - DMCasino
    Merkur 37C Safety Razor Features Merkur Classic Double Edge Safety Razor with Heavy Duty Handle, 바카라 사이트 German design and is ideal for all men from all walks of life.Features: Closed CombWeight: 90gWeight: 90g Rating: deccasino 3 · ‎3 งานออนไลน์ votes · ‎$39.00 · ‎In stock

    ReplyDelete