I am trying to query dynamics crm accounts data with regex to compare with the account name as a duplicate detection measure to populate a warning to the end user with a confirm dialog, where user can proceed with creating a duplicate account name if they require. Here, in the query, I am trying to filter the account names ignoring any spaces within the names, then comparing it with the account name being created/updated and then populate a warning if the string matches. I intend to use js as OOB duplicate detection seem to match the complete word only and plugin would restrict the user creating a duplicate record completely.
Please suggest a way to achieve the same
I tried the following code which results in error, I have also tried Microsoft.Dynamics.CRM.Contains, which results in error too
var accountName = formContext.getAttribute("name").getValue().replace(/\s+/g, '');
var query = "?$select=name&$filter=contains(replace(name, ' ', ''),'" + accountName + "') and statecode eq 0";