Search This Blog

Thursday, January 2, 2014

Run dialogue by clicking Button

function project_code()//project code button
{
var dialogId = "{E8F6C5EC-E606-447E-B253-C950FB6F29B2}"; // dialogue id
var typeName = "salesorder";
var recordId = Xrm.Page.data.entity.getId();
LaunchModalDialog(dialogId,typeName,recordId);
//alert("project code");
}

function project_manager()//project manager button
{
var dialogId = "{6322F944-7202-4EDF-81A0-3EFAB678068D}"; // dialogue id
var typeName = "salesorder";
var recordId = Xrm.Page.data.entity.getId();
LaunchModalDialog(dialogId,typeName,recordId);
//alert("project manager");
}
//**This function will run buttons and dialogs working on these button**//
function LaunchModalDialog(dialogId,typeName,recordId)
{
    var serverUrl = Xrm.Page.context.getServerUrl();
    recordId=recordId.replace("{", "");
    recordId=recordId.replace("}", "");
   
    dialogId=dialogId.replace("{", "");
    dialogId=dialogId.replace("}", "");
   
   //var project_code_id = {E8F6C5EC-E606-447E-B253-C950FB6F29B2};
   //var project_manager_id = {6322F944-7202-4EDF-81A0-3EFAB678068D};

   var serverUri = serverUrl +'/cs/dialog/rundialog.aspx';
   var mypath =  serverUri +'?DialogId=%7b' +dialogId.toUpperCase()  +'%7d&EntityName=' + typeName+'&ObjectId=%7b' +recordId+'%7d';
 
   //var mypath =  serverUri +'?DialogId=%7b' +project_code_id.toUpperCase()  +'%7d&EntityName=' + typeName+'&ObjectId=%7b' +recordId+'%7d';
   // First item from selected contacts only
   window.showModalDialog(mypath);
 
   // Reload form.
   window.location.reload(true);
}

No comments:

Post a Comment