HTML Dropdown

Friday, 9 September 2016

Duplicate Detection using JQuery/OData in CRM 2013 Part2


Step5: Create new Entity Duplicate Detection Test. The main purpose of this entity is to provide another example using a variety of different custom attributes of different types.


Create N:1 Relationship between Account and Duplicate Detection Entity


On FormOnSave Event Call SDK.DuplicateDetection.js


Pass the Execution Parameter Like Below:-

false, "sample_duplicatedetecttest",  "sample_duplicatedetecttestid",  ["sample_name","sample_account","sample_bool","sample_date","sample_decimal","sample_double","sample_integer","sample_memo", "sample_money","sample_optionset"], "sample_/duplicateDetection/ShowDuplicateTests.html", "dialogHeight: 250px; dialogWidth: 800px; resizable: yes; status: no;"

Step6: Add the following JavaScript to show duplicate Contact

/// <reference path="../../jQuery/jquery_1.9.1_vsdoc.js" />

 

 

 

$(function () {

 

 

 $("#btnSave").on("click", save);

 $("#btnCancel").on("click", cancel);

 

 if (typeof dialogArguments != "undefined" && typeof dialogArguments != null) {

 

 

   showRecords();

 

 

 }

 

});

 

 

function selectRow() {

 $(".sdk-sample-List-SelectedRow").removeClass("sdk-sample-List-SelectedRow").addClass("sdk-sample-List-Row");

 $(this).removeClass("sdk-sample-List-Row");

 $(this).addClass("sdk-sample-List-SelectedRow");

}

 

function showRecords() {

 var summaryMessage = "";

 var numberOfRecords = dialogArguments.length;

 var resultsTable = $("<table class='sdk-sample-List-Data' id='gridBodyTable' />");

 resultsTable.attr("border", 1);

 resultsTable.attr("cellspacing", 0);

 resultsTable.attr("cellpadding", 1);

 

 

 if (numberOfRecords > 1)

 { summaryMessage = "This list contains " + numberOfRecords + " Contact records." }

 else

 {

  summaryMessage = "This list contains 1 Contact record."

  var DlgHdTitleText = "Potential Duplicate Contact Detected";

  $("#DlgHdTitle").text(DlgHdTitleText);

  $("#DlgHdTitle").attr("title", DlgHdTitleText);

  var DlgHdDescText = "This contact may be a duplicate of the contact below."

  $("#DlgHdDesc").text(DlgHdDescText);

  $("#DlgHdDesc").attr("title", DlgHdDescText);

 

 }

 resultsTable.attr("summary", summaryMessage);

 

 var colGroup = $("<colgroup />");

 colGroup.append($("<col width='200' class='sdk-sample-List-DataColumn' name='fullname' />"));

 colGroup.append($("<col width='200' class='sdk-sample-List-DataColumn' name='emailaddress1' />"));

 resultsTable.append(colGroup);

 

 for (var i = 0; i < dialogArguments.length; i++) {

  var record = dialogArguments[i];

  var row = $("<tr class='sdk-sample-List-Row' otypename='contact' oid=" + record.id + " />");

  //fullName column

  var fullnameCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var fullnameGridcellpadding = $("<nobr class='gridcellpadding' />");

  var fullnameLink = $("<a class='sdk-sample-List-Link' />");

  fullnameLink.attr("title", record.fullname)

  fullnameLink.attr("tabindex", i)

  fullnameLink.attr("href", "#")

  fullnameLink.attr("target", "_blank")

  fullnameLink.attr("oid", record.id)

  fullnameLink.attr("otypename", 'contact')

 

  if (typeof record.fullname != "undefined") {

   // Quick Create form can't have fullname in the attributes

   fullnameLink.text(record.fullname);

  }

  else {

   fullnameLink.text(record.firstname +" "+record.lastname);

  }

 

 

  fullnameGridcellpadding.append(fullnameLink);

  fullnameCell.append(fullnameGridcellpadding);

  fullnameCell.append(fullnameGridcellpadding);

  row.append(fullnameCell);

  fullnameLink.on("click", openRecord);

 

  //emailaddress1 column

  var emailaddress1Cell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var emailaddress1Gridcellpadding = $("<nobr class='gridcellpadding' />");

  emailaddress1Gridcellpadding.attr("title", record.emailaddress1)

  emailaddress1Gridcellpadding.text(record.emailaddress1);

  emailaddress1Cell.append(emailaddress1Gridcellpadding);

  row.append(emailaddress1Cell);

 

  //spacer Column

  row.append($("<td class='sdk-sample-List-DataCell'><nobr class='gridcellpadding'></nobr></td>"));

 

  row.on("click", selectRow);

  row.on("dblclick", openRecord);

 

  resultsTable.append(row);

 

 }

 $("#DlgHdBodyContainer").append(resultsTable);

 

}

 

function openRecord() {

 var type = $(this).attr("otypename");

 var id = $(this).attr("oid");

 window.returnValue = { "type": type, "id": id };

 window.close();

 return false;

}

 

 function save() {

  window.returnValue = "save";

  window.close();

 }

 function cancel() {

  window.returnValue = "cancel";

  window.close();

 }

Step7: Add following JavaScript to show duplicate Leads

/// <reference path="../../jQuery/jquery_1.9.1_vsdoc.js" />

 

 

 

$(function () {

 

 

 $("#btnSave").on("click", save);

 $("#btnCancel").on("click", cancel);

 

 if (typeof dialogArguments != "undefined" && typeof dialogArguments != null) {

 

 

   showRecords();

 

 

 }

 

});

 

 

function selectRow() {

 $(".sdk-sample-List-SelectedRow").removeClass("sdk-sample-List-SelectedRow").addClass("sdk-sample-List-Row");

 $(this).removeClass("sdk-sample-List-Row");

 $(this).addClass("sdk-sample-List-SelectedRow");

}

 

function showRecords() {

 var summaryMessage = "";

 var numberOfRecords = dialogArguments.length;

 var resultsTable = $("<table class='sdk-sample-List-Data' id='gridBodyTable' />");

 resultsTable.attr("border", 1);

 resultsTable.attr("cellspacing", 0);

 resultsTable.attr("cellpadding", 1);

 

 

 if (numberOfRecords > 1)

 { summaryMessage = "This list contains " + numberOfRecords + " Lead records." }

 else

 {

  summaryMessage = "This list contains 1 Lead record."

  var DlgHdTitleText = "Potential Duplicate Lead Detected";

  $("#DlgHdTitle").text(DlgHdTitleText);

  $("#DlgHdTitle").attr("title", DlgHdTitleText);

  var DlgHdDescText = "This lead may be a duplicate of the lead below."

  $("#DlgHdDesc").text(DlgHdDescText);

  $("#DlgHdDesc").attr("title", DlgHdDescText);

 

 }

 resultsTable.attr("summary", summaryMessage);

 

 var colGroup = $("<colgroup />");

 colGroup.append($("<col width='175' class='sdk-sample-List-DataColumn' name='topic' />"));

 colGroup.append($("<col width='175' class='sdk-sample-List-DataColumn' name='fullname' />"));

 colGroup.append($("<col width='175' class='sdk-sample-List-DataColumn' name='address1_city' />"));

 colGroup.append($("<col width='175' class='sdk-sample-List-DataColumn' name='emailaddress1' />"));

 resultsTable.append(colGroup);

 

 for (var i = 0; i < dialogArguments.length; i++) {

  var record = dialogArguments[i];

  var row = $("<tr class='sdk-sample-List-Row' otypename='lead' oid=" + record.id + " />");

 

 

  //subject column

  var subjectCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var subjectGridcellpadding = $("<nobr class='gridcellpadding' />");

  var subjectLink = $("<a class='sdk-sample-List-Link' />");

  subjectLink.attr("title", record.subject)

  subjectLink.attr("tabindex", i)

  subjectLink.attr("href", "#")

  subjectLink.attr("target", "_blank")

  subjectLink.attr("oid", record.id)

  subjectLink.attr("otypename", 'lead')

  subjectLink.text(record.subject);

  subjectGridcellpadding.append(subjectLink);

  subjectCell.append(subjectGridcellpadding);

  subjectCell.append(subjectGridcellpadding);

  row.append(subjectCell);

  subjectLink.on("click", openRecord);

 

 

  //fullname column

  var fullnameCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var fullnameGridcellpadding = $("<nobr class='gridcellpadding' />");

  fullnameGridcellpadding.attr("title", record.fullname)

  if (typeof record.fullname != "undefined")

  {

   fullnameGridcellpadding.text(record.fullname);

  }

  else

  {

   fullnameGridcellpadding.text(record.firstname + " " + record.lastname);

  }

  fullnameCell.append(fullnameGridcellpadding);

  row.append(fullnameCell);

 

 

 

  //address1_city column

  var address1_cityCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var address1_cityGridcellpadding = $("<nobr class='gridcellpadding' />");

  address1_cityGridcellpadding.attr("title", record.address1_city)

  address1_cityGridcellpadding.text(record.address1_city);

  address1_cityCell.append(address1_cityGridcellpadding);

  row.append(address1_cityCell);

 

 

  //emailaddress1 column

  var emailaddress1Cell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var emailaddress1Gridcellpadding = $("<nobr class='gridcellpadding' />");

  emailaddress1Gridcellpadding.attr("title", record.emailaddress1)

  emailaddress1Gridcellpadding.text(record.emailaddress1);

  emailaddress1Cell.append(emailaddress1Gridcellpadding);

  row.append(emailaddress1Cell);

 

 

 

 

 

  //spacer Column

  row.append($("<td class='sdk-sample-List-DataCell'><nobr class='gridcellpadding'></nobr></td>"));

 

  row.on("click", selectRow);

  row.on("dblclick", openRecord);

 

  resultsTable.append(row);

 

 }

 $("#DlgHdBodyContainer").append(resultsTable);

 

}

 

function openRecord() {

 var type = $(this).attr("otypename");

 var id = $(this).attr("oid");

 window.returnValue = { "type": type, "id": id };

 window.close();

 return false;

}

 

 function save() {

  window.returnValue = "save";

  window.close();

 }

 function cancel() {

  window.returnValue = "cancel";

  window.close();

 }

Step8: Add following JavaScript to add duplicate test

/// <reference path="../../jQuery/jquery_1.9.1_vsdoc.js" />

 

 

 

$(function () {

 

 

 $("#btnSave").on("click", save);

 $("#btnCancel").on("click", cancel);

 

 if (typeof dialogArguments != "undefined" && typeof dialogArguments != null) {

 

 

   showRecords();

 

 

 }

 

});

 

 

function selectRow() {

 $(".sdk-sample-List-SelectedRow").removeClass("sdk-sample-List-SelectedRow").addClass("sdk-sample-List-Row");

 $(this).removeClass("sdk-sample-List-Row");

 $(this).addClass("sdk-sample-List-SelectedRow");

}

 

function showRecords() {

 var summaryMessage = "";

 var numberOfRecords = dialogArguments.length;

 var resultsTable = $("<table class='sdk-sample-List-Data' id='gridBodyTable' />");

 resultsTable.attr("border", 1);

 resultsTable.attr("cellspacing", 0);

 resultsTable.attr("cellpadding", 1);

 

 

 if (numberOfRecords > 1)

 { summaryMessage = "This list contains " + numberOfRecords + " Test records." }

 else

 {

  summaryMessage = "This list contains 1 Test record."

  var DlgHdTitleText = "Potential Duplicate Test Detected";

  $("#DlgHdTitle").text(DlgHdTitleText);

  $("#DlgHdTitle").attr("title", DlgHdTitleText);

  var DlgHdDescText = "This test may be a duplicate of the test below."

  $("#DlgHdDesc").text(DlgHdDescText);

  $("#DlgHdDesc").attr("title", DlgHdDescText);

 

 }

 resultsTable.attr("summary", summaryMessage);

 

 var colGroup = $("<colgroup />");

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_name' />"));

 colGroup.append($("<col width='100' class='sdk-sample-List-DataColumn' name='sample_account' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_bool' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_date' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_decimal' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_double' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_integer' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_memo' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_money' />"));

 colGroup.append($("<col width='50' class='sdk-sample-List-DataColumn' name='sample_optionset' />"));

 colGroup.append($("<col />"));

 resultsTable.append(colGroup);

 

 for (var i = 0; i < dialogArguments.length; i++) {

  var record = dialogArguments[i];

  var row = $("<tr class='sdk-sample-List-Row' otypename='sample_duplicatedetecttest' oid=" + record.id + " />");

 

 

  //sample_name column

  var sample_nameCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_nameGridcellpadding = $("<nobr class='gridcellpadding' />");

  var sample_nameLink = $("<a class='sdk-sample-List-Link' />");

  sample_nameLink.attr("title", record.sample_name)

  sample_nameLink.attr("tabindex", i)

  sample_nameLink.attr("href", "#")

  sample_nameLink.attr("target", "_blank")

  sample_nameLink.attr("oid", record.id)

  sample_nameLink.attr("otypename", 'sample_duplicatedetecttest')

  sample_nameLink.text(record.sample_name);

  sample_nameGridcellpadding.append(sample_nameLink);

  sample_nameCell.append(sample_nameGridcellpadding);

  sample_nameCell.append(sample_nameGridcellpadding);

  row.append(sample_nameCell);

  sample_nameLink.on("click", openRecord);

 

  ////primary_attribute_name column

  //var primary_attribute_nameCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  //var primary_attribute_nameGridcellpadding = $("<nobr class='gridcellpadding' />");

  //var primary_attribute_nameLink = $("<a class='sdk-sample-List-Link' />");

  //primary_attribute_nameLink.attr("title", record.primary_attribute_name)

  //primary_attribute_nameLink.attr("tabindex", i)

  //primary_attribute_nameLink.attr("href", "#")

  //primary_attribute_nameLink.attr("target", "_blank")

  //primary_attribute_nameLink.attr("oid", record.id)

  //primary_attribute_nameLink.attr("otypename", 'sample_duplicatedetecttest')

  //primary_attribute_nameLink.text(record.primary_attribute_name);

  //primary_attribute_nameGridcellpadding.append(primary_attribute_nameLink);

  //primary_attribute_nameCell.append(primary_attribute_nameGridcellpadding);

  //primary_attribute_nameCell.append(primary_attribute_nameGridcellpadding);

  //row.append(primary_attribute_nameCell);

  //primary_attribute_nameLink.on("click", openRecord);

 

 

  //sample_account column

  var sample_accountCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_accountGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_accountGridcellpadding.attr("title", record.sample_account)

  sample_accountGridcellpadding.text(record.sample_account);

  sample_accountCell.append(sample_accountGridcellpadding);

  row.append(sample_accountCell);

 

 

  //sample_bool column

  var sample_boolCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_boolGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_boolGridcellpadding.attr("title", record.sample_bool)

  sample_boolGridcellpadding.text(record.sample_bool);

  sample_boolCell.append(sample_boolGridcellpadding);

  row.append(sample_boolCell);

 

  //sample_date column

  var sample_dateCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_dateGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_dateGridcellpadding.attr("title", record.sample_date)

  sample_dateGridcellpadding.text(record.sample_date);

  sample_dateCell.append(sample_dateGridcellpadding);

  row.append(sample_dateCell);

 

  //sample_decimal column

  var sample_decimalCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_decimalGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_decimalGridcellpadding.attr("title", record.sample_decimal)

  sample_decimalGridcellpadding.text(record.sample_decimal);

  sample_decimalCell.append(sample_decimalGridcellpadding);

  row.append(sample_decimalCell);

 

  //sample_double column

  var sample_doubleCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_doubleGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_doubleGridcellpadding.attr("title", record.sample_double)

  sample_doubleGridcellpadding.text(record.sample_double);

  sample_doubleCell.append(sample_doubleGridcellpadding);

  row.append(sample_doubleCell);

 

  //sample_integer column

  var sample_integerCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_integerGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_integerGridcellpadding.attr("title", record.sample_integer)

  sample_integerGridcellpadding.text(record.sample_integer);

  sample_integerCell.append(sample_integerGridcellpadding);

  row.append(sample_integerCell);

 

  //sample_memo column

  var sample_memoCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_memoGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_memoGridcellpadding.attr("title", record.sample_memo)

  sample_memoGridcellpadding.text(record.sample_memo);

  sample_memoCell.append(sample_memoGridcellpadding);

  row.append(sample_memoCell);

 

  //sample_money column

  var sample_moneyCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_moneyGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_moneyGridcellpadding.attr("title", record.sample_money)

  sample_moneyGridcellpadding.text(record.sample_money);

  sample_moneyCell.append(sample_moneyGridcellpadding);

  row.append(sample_moneyCell);

 

  //sample_optionset column

  var sample_optionsetCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  var sample_optionsetGridcellpadding = $("<nobr class='gridcellpadding' />");

  sample_optionsetGridcellpadding.attr("title", record.sample_optionset)

  sample_optionsetGridcellpadding.text(record.sample_optionset);

  sample_optionsetCell.append(sample_optionsetGridcellpadding);

  row.append(sample_optionsetCell);

 

  // Find/Replace the attribute name

  ////attributeName column

  //var attributeNameCell = $("<td class='sdk-sample-List-DataCell inner-grid-cellPadding' />");

  //var attributeNameGridcellpadding = $("<nobr class='gridcellpadding' />");

  //attributeNameGridcellpadding.attr("title", record.attributeName)

  //attributeNameGridcellpadding.text(record.attributeName);

  //attributeNameCell.append(attributeNameGridcellpadding);

  //row.append(attributeNameCell);

 

 

 

 

 

 

  //spacer Column

  row.append($("<td class='sdk-sample-List-DataCell'><nobr class='gridcellpadding'></nobr></td>"));

 

  row.on("click", selectRow);

  row.on("dblclick", openRecord);

 

  resultsTable.append(row);

 

 }

 $("#DlgHdBodyContainer").append(resultsTable);

 

}

 

function openRecord() {

 var type = $(this).attr("otypename");

 var id = $(this).attr("oid");

 window.returnValue = { "type": type, "id": id };

 window.close();

 return false;

}

 

 function save() {

  window.returnValue = "save";

  window.close();

 }

 function cancel() {

  window.returnValue = "cancel";

  window.close();

 }

Step9: Add the following Html to show duplicate contact in Webresource


<!DOCTYPE HTML >

<html>

<head>

 <title>Duplicates Found</title>

 <link href="styles/ShowDuplicates.css" rel="stylesheet" />

 <script src="../jQuery/jquery_1.9.1.min.js"></script>

 <script src="../../ClientGlobalContext.js.aspx" type="text/javascript" ></script>

 <script src="scripts/ShowDuplicateContacts.js"></script>

</head>

<body>

 <div style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 44px;">

  <div class="sdk-sample-Dialog-Header">

   <div title="Potential Duplicate Contacts Detected"

    class="sdk-sample-Dialog-Header-Title sdk-sample-TextAutoEllipsis"

    id="DlgHdTitle" style="width: calc(100% - 95px) !important;">

    Potential Duplicate Contacts Detected

 

   </div>

  

   <div title="This contact may be a duplicate of the contacts below."

    class="sdk-sample-Dialog-Header-Desc" id="DlgHdDesc">

    This contact may be a duplicate of the contacts below.

   </div>

   <div style="margin-top: 10px; position: relative; overflow-x: hidden;">

    <div class="sdk-sample-ListArea-FixedRow" id="fixedrow" style="margin-left: 0px;">

     <table class="sdk-sample-List-Header" id="crmGrid_gridBar" cellspacing="0" cellpadding="0">

      <colgroup id="crmGrid_gridBarCols">

       <!--Full Name Header Column-->

       <col width="200" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col width="2" />

       <!--EMail  Header Column-->

       <col width="200" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col />

      </colgroup>

      <tbody>

       <tr style="height: 24px;">

        <th class="sdk-sample-List-Sortable" scope="col">

         <!--Full Name Header Column-->

         <nobr class="sdk-sample-DataCell">

          <label title="Full Name" class="sdk-sample-List-Sortable">Full Name</label>               

         </nobr>

        </th>

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"      

          src="images/resize.png" />

        </td>

        <!--EMail  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Email" class="sdk-sample-List-Sortable">Email</label>                        

         </nobr>

        </th>

        <!--Spacer-->

        <td></td>

       </tr>

      </tbody>

     </table>

    </div>

   </div>

  </div>

  <div class="sdk-sample-Dialog-Main" id="DlgHdBodyContainer"></div>

 </div>

 <div class="sdk-sample-Dialog-Footer" id="crmDialogFooter">

  <div class="sdk-sample-Dialog-Footer-Right">

   <button tabindex="51" class="sdk-sample-Dialog-Button" id="btnSave" style="margin-left: 8px;" type="button">Save Anyway</button>

   <button tabindex="52" class="sdk-sample-Dialog-Button" id="btnCancel" style="margin-left: 8px;" type="button">Cancel</button>

  </div>

 </div>

</body>

</html>

Step10: Add the following HTML to show duplicate Leads in WebResourse


<!DOCTYPE HTML >

<html>

<head>

 <title>Duplicates Found</title>

 <link href="styles/ShowDuplicates.css" rel="stylesheet" />

 <script src="../jQuery/jquery_1.9.1.min.js"></script>

 <script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>

 <script src="scripts/ShowDuplicateLeads.js"></script>

</head>

<body>

 <div style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 44px;">

  <div class="sdk-sample-Dialog-Header">

   <div title="Potential Duplicate Leads Detected"

    class="sdk-sample-Dialog-Header-Title sdk-sample-TextAutoEllipsis"

    id="DlgHdTitle" style="width: calc(100% - 95px) !important;">

    Potential Duplicate Leads Detected

 

   </div>

 

   <div title="This lead may be a duplicate of the leads below."

    class="sdk-sample-Dialog-Header-Desc" id="DlgHdDesc">

    This lead may be a duplicate of the leads below.

   </div>

   <div style="margin-top: 10px; position: relative; overflow-x: hidden;">

    <div class="sdk-sample-ListArea-FixedRow" id="fixedrow" style="margin-left: 0px;">

     <table class="sdk-sample-List-Header" id="crmGrid_gridBar" cellspacing="0" cellpadding="0">

      <colgroup id="crmGrid_gridBarCols">

       <!--Topic Header Column-->

       <col width="175" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col width="2" />

       <!--Full Name Header Column-->

       <col width="175" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col width="2" />

       <!--City  Header Column-->

       <col width="175" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col width="2" />

       <!--Email  Header Column-->

       <col width="175" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col />

      </colgroup>

      <tbody>

       <tr style="height: 24px;">

         <!--Topic Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">       

         <nobr class="sdk-sample-DataCell">

          <label title="Topic" class="sdk-sample-List-Sortable">Topic</label>               

         </nobr>

        </th>

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

         <!--Full Name Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

          <label title="Full Name" class="sdk-sample-List-Sortable">Full Name</label>               

         </nobr>

        </th>

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--City  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="City" class="sdk-sample-List-Sortable">City</label>                        

         </nobr>

        </th>

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--EMail  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Email" class="sdk-sample-List-Sortable">Email</label>                        

         </nobr>

        </th>

 

        <!--Spacer-->

        <td></td>

       </tr>

      </tbody>

     </table>

    </div>

   </div>

  </div>

  <div class="sdk-sample-Dialog-Main" id="DlgHdBodyContainer"></div>

 </div>

 <div class="sdk-sample-Dialog-Footer" id="crmDialogFooter">

  <div class="sdk-sample-Dialog-Footer-Right">

   <button tabindex="51" class="sdk-sample-Dialog-Button" id="btnSave" style="margin-left: 8px;" type="button">Save Anyway</button>

   <button tabindex="52" class="sdk-sample-Dialog-Button" id="btnCancel" style="margin-left: 8px;" type="button">Cancel</button>

  </div>

 </div>

</body>

</html>

Step11: Add the following HTML to add Duplicate Test in Web Resource


<!DOCTYPE HTML >

<html>

<head>

 <title>Duplicates Found</title>

 <link href="styles/ShowDuplicates.css" rel="stylesheet" />

 <script src="../jQuery/jquery_1.9.1.min.js"></script>

 <script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>

 <script src="scripts/ShowDuplicateTests.js"></script>

</head>

<body>

 <div style="position: absolute; left: 0px; right: 0px; top: 0px; bottom: 44px;">

  <div class="sdk-sample-Dialog-Header">

   <div title="Potential Duplicate Tests Detected"

    class="sdk-sample-Dialog-Header-Title sdk-sample-TextAutoEllipsis"

    id="DlgHdTitle" style="width: calc(100% - 95px) !important;">

    Potential Duplicate Tests Detected

 

   </div>

 

   <div title="This test may be a duplicate of the tests below."

    class="sdk-sample-Dialog-Header-Desc" id="DlgHdDesc">

    This test may be a duplicate of the tests below.

   </div>

   <div style="margin-top: 10px; position: relative; overflow-x: hidden;">

    <div class="sdk-sample-ListArea-FixedRow" id="fixedrow" style="margin-left: 0px;">

     <table class="sdk-sample-List-Header" id="crmGrid_gridBar" cellspacing="0" cellpadding="0">

      <colgroup id="crmGrid_gridBarCols">

       <!--Name Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col width="2" />

       <!--Account Header Column-->

       <col width="100" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col width="2" />

       <!--Bool  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col width="2" />

       <!--Date  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

        <col width="2" />

       <!--Decimal  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

         <!--Spacer-->

        <col width="2" />

       <!--Double  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

         <!--Spacer-->

        <col width="2" />

       <!--Integer  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

         <!--Spacer-->

        <col width="2" />

       <!--Memo  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

         <!--Spacer-->

        <col width="2" />

       <!--Money  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

         <!--Spacer-->

        <col width="2" />

       <!--OptionSet  Header Column-->

       <col width="50" class="sdk-sample-List-DataColumnHeader" />

       <!--Spacer-->

       <col />

      </colgroup>

      <tbody>

       <tr style="height: 24px;">

         <!-- Name Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

          <label title="Name" class="sdk-sample-List-Sortable">Name</label>               

         </nobr>

        </th>

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Account  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Account" class="sdk-sample-List-Sortable">Account</label>                         

         </nobr>

        </th>

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Bool  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Bool" class="sdk-sample-List-Sortable">Bool</label>                        

         </nobr>

        </th>

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Date  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Date" class="sdk-sample-List-Sortable">Date</label>                        

         </nobr>

        </th>

 

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Decimal  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Decimal" class="sdk-sample-List-Sortable">Decimal</label>                        

         </nobr>

        </th>

 

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Double  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Double" class="sdk-sample-List-Sortable">Double</label>                        

         </nobr>

        </th>

 

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Integer  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Integer" class="sdk-sample-List-Sortable">Integer</label>                        

         </nobr>

        </th>

 

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Memo  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Memo" class="sdk-sample-List-Sortable">Memo</label>                        

         </nobr>

        </th>

 

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--Money  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="Bool" class="sdk-sample-List-Sortable">Money</label>                        

         </nobr>

        </th>

 

        <!--Spacer-->

        <td>

         <img class="sdk-sample-List-ResizeBar sdk-sample-ImageStrip-resize"

          src="images/resize.png" />

        </td>

        <!--OptionSet  Header Column-->

        <th class="sdk-sample-List-Sortable" scope="col">

         <nobr class="sdk-sample-DataCell">

           <label title="OptionSet" class="sdk-sample-List-Sortable">OptionSet</label>                        

         </nobr>

        </th>

 

 

        <!--Spacer-->

        <td></td>

       </tr>

      </tbody>

     </table>

    </div>

   </div>

  </div>

  <div class="sdk-sample-Dialog-Main" id="DlgHdBodyContainer"></div>

 </div>

 <div class="sdk-sample-Dialog-Footer" id="crmDialogFooter">

  <div class="sdk-sample-Dialog-Footer-Right">

   <button tabindex="51" class="sdk-sample-Dialog-Button" id="btnSave" style="margin-left: 8px;" type="button">Save Anyway</button>

   <button tabindex="52" class="sdk-sample-Dialog-Button" id="btnCancel" style="margin-left: 8px;" type="button">Cancel</button>

  </div>

 </div>

</body>

</html>

Step 12: add CSS , jpeg, sitemap and JQuery  Files as web resource in CRM solution from CRM 2013 SDK



Contents


This solution contains the following major components:

Name
Type
Description
SDK.DuplicateDetection.js
JavaScript Web Resource
This library provides the core components of this sample. It contains the SDK.Sample.DuplicateDetection.onSave function that is set to the OnSave event handler. You do not need to edit the contents of this library.
Duplicate Detect Test
Custom Entity
This custom entity includes a number of different fields used to verify the functionality of this sample. The main form is configured with an example in the main form
Account
System entity
The Account entity is included because the Duplicate Detect Test entity has a lookup to the account entity. It is not configured for duplicate detection
Contact
System entity
The Contact entity has two forms with OnSave event handlers configured to detect duplicate records.
Lead
System entity
The Lead entity has two forms with OnSave event handlers configured to detect duplicate records.
ShowDuplicateContacts.html
HTML Web Resource
This HTML web resource is launched as a modal dialog when a duplicate record is detected on a save event for the Contact entity
ShowDuplicateContacts.js
JavaScript Web Resource
This JavaScript web resource provides the logic to show duplicate records for ShowDuplicateContacts.html.
ShowDuplicateLeads.html
HTML Web Resource
This HTML web resource is launched as a modal dialog when a duplicate record is detected on a save event for the Lead entity
ShowDuplicateLeads.js
JavaScript Web Resource
This JavaScript web resource provides the logic to show duplicate records for ShowDuplicateLeads.html.
ShowDuplicateTests.html
HTML Web Resource
This HTML web resource is launched as a modal dialog when a duplicate record is detected on a save event for the Duplicate Detect Test entity.
ShowDuplicateTests.js
JavaScript Web Resource
This JavaScript web resource provides the logic to show duplicate records for ShowDuplicateTests.html.
jquery_1.9.1.min.js
JavaScript Web Resource
Each of the ShowDuplicate* web resources depend on jQuery.
ShowDuplicates.css
CSS Web Resource
Each of the ShowDuplicate* html web resources includes a link to this style sheet.


 Testing:


Click on Cancel if you do not want to save.


Click on Save Anyway


Click on Save

Create new Record on Duplicate Detection Test Entity


 

 

No comments:

Post a Comment