Profile matching and merging in integration scripts

2019-10-08 19:37:00.0
Developers

The video below shows setting up a system integration process to import profile (ie customer) data from a remote source.

This process matched existing customers where possible, and when new information allows existing profiles to be identified as duplicates merges them.

This is just a simple introduction, the matching API offers many more factors for matching profiles.

Source code used in the demo

controllers.xml


    
    

   

 

import-custs.xml


    
        
            /integration/check-custs.js
            checkCusts

            
                
                
                
                
                 
                
            

        
    

 

check-custs.js

function checkCusts(firstName, surName, phone, email) {   
    var matchReq = userManager.newProfileMatchRequest().or();
    // this will return all profiles matching all given non-blank params
    
    if( email ) {
        matchReq.newSubCriteria().and()
            .firstName(firstName)
            .email(email);    
    }
    
    if( phone ) {
        matchReq.newSubCriteria().and()
            .firstName(firstName)
            .phone(phone);
    }
    
    var matched = userManager.findMatching(matchReq);
    log.info("Matched {} profiles", matched.size());
    if( matched.size() == 0 ) {
        nextStep.exec(firstName, surName, phone, email, null);
    } else if( matched.size() == 1) {
        var existing = matched.get(0);
        nextStep.exec(firstName, surName, phone, email, existing.userName);
    } else {
        // Choose the first as the merge target. Merge others into that, and then continue with it
        var mergeDest = matched.get(0);
        matched.remove(0);
        userManager.mergeProfiles(mergeDest, matched);
        nextStep.exec(firstName, surName, phone, email, mergeDest.userName);
    }
}

 

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro labore architecto fuga tempore omnis aliquid, rerum numquam deleniti ipsam earum velit aliquam deserunt, molestiae officiis mollitia accusantium suscipit fugiat esse magnam eaque cumque, iste corrupti magni? Illo dicta saepe, maiores fugit aliquid consequuntur aut, rem ex iusto dolorem molestias obcaecati eveniet vel voluptatibus recusandae illum, voluptatem! Odit est possimus nesciunt.