function getDuplicates(executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() != 1) {
var duplicatesGridControl = formContext.getControl("Duplicates");
if (duplicatesGridControl == null) {
setTimeout(function () { getDuplicates(executionContext); }, 2000);
} else {
var leadId = formContext.data.entity.getId().replace("{", "").replace("}", "");
var firstName = formContext.getAttribute('firstname')?.getValue();
var lastName = formContext.getAttribute('lastname')?.getValue();
var topic = formContext.getAttribute('subject')?.getValue();
var fetchXml = `
<fetch>
<entity name='lead'>
<attribute name='fullname'/>
<filter type='and'>
<condition attribute='firstname' operator='eq' value='${firstName}' />
<condition attribute='lastname' operator='eq' value='${lastName}' />
<condition attribute='subject' operator='eq' value='${topic}' />
<condition attribute='leadid' operator='ne' value='${leadId}' />
</filter>
</entity>
</fetch>
`;
duplicatesGridControl.setFilterXml(fetchXml);
duplicatesGridControl.refresh();
var summaryObj = formContext.ui.tabs.get("Summary");
var duplicatesObj = summaryObj.sections.get("Summary_Duplicates");
duplicatesObj.setVisible(true);
}
}
}