0 votes

Question from a partner :

Is it possible to manipulate the values selected before/during a merge of duplicates (and if so, howto do it ?)

For a duplication merge, the highest type and subtype should be preselected.

Type/ Subtype ranking (1 = highest ranking):
1. Customer / Collector
2. Customer / VIC
3. Customer / Promising Customer
4. Customer / Stated Owner
5. Customer / Former Owner
6. Prospect / VIP
7. Prospect / Promising Prospect
8. Prospect / Appreciated Prospect

Currently, the type and subtype are preselected from the contact that was last edited. Yes you can change it, but it happens, that a customer being turned into a prospect. Now we would like to change the default settings.

asked in WorkFlow / Serverscript by (618 points)

1 Answer

0 votes

Stijn, does this https://help.efficy.com/edn/dev/svjs_prepareduplicatemerge example help you?

function PrepareDuplicateMerge(Key2, Key1, DataSet) {
  // loop through the data set of all the fields available for the entities being merged
  DataSet.first
  while (!DataSet.Eof) {
    // if the field is a candidate for merging, we go further inside it
    if (DataSet.fieldByName('TOMERGE').AsString == 'True') {
      // check the fields Name and First Name
      if (DataSet.fieldByName('FIELDNAME').AsString == 'NAME' || DataSet.fieldByName('FIELDNAME').AsString == 'FIRSTNAME') {
        // if the only difference is the case
        if (DataSet.fieldByName('VALUE').AsString.toUpperCase() == DataSet.fieldByName('VALUE2').AsString.toUpperCase()) {
          var Name1Upper = false
          var Name2Upper = false
          if (DataSet.fieldByName('VALUE').AsString == DataSet.fieldByName('VALUE').AsString.toUpperCase())
            Name1Upper = true
          if (DataSet.fieldByName('VALUE2').AsString == DataSet.fieldByName('VALUE2').AsString.toUpperCase())
            Name2Upper = true
          if ((Name1Upper) && (!Name2Upper)) {
            DataSet.edit
            // set the selection to the second entity (right entity)
            DataSet.fieldByName('SELECTED').AsInteger = 2
          }
          if ((!Name1Upper) && (Name2Upper)) {
            DataSet.fieldByName
            // set the selection to the first entity (left entity)
            DataSet.fieldByName('SELECTED').AsInteger = 1
          }
        }
      }
    }
    DataSet.next
  }
}
answered by (7.4k points)
1,248 questions
1,518 answers
1,858 comments
328 users