Preventing creation of new interaction and redirecting to the original interaction

Shyna1
Tera Contributor

Hello,

We use Genesys tool for calls which creates interactions in SOW in ServiceNow. It has been seen that there are duplicate interactions being created with same genesys Interaction ID but with different interaction numbers in servicenow which is considered as a duplicate because it is generating same interaction ID. 

NOTE: Genesys interaction id is a field in ServiceNow which  gets populated automatically when genesys hits the ServiceNow api .

We are applying a fix to prevent the creation of duplicate interaction in ServiceNow . I have written a before BR and it is working as expected. i.e. When second time the genesys tries to hit ServiceNow API with similar genesys interaction ID it opens the new interaction record page and displays the error as mentioned in the BR and aborts the creation/saving of interaction.

Our requirement is I do not want the new interaction record page to be open at all. I.E. whenever there is a duplicate call landing in ServiceNow , it should not open the new record interaction page with error message but redirect to the original interaction already created.

Below is the BR:

 

(function executeRule(current, previous /*null when async*/ ) {

    var inteGR = new GlideRecord('interaction');
    inteGR.addEncodedQuery('u_genesys_interaction_id!=NULL^u_genesys_interaction_id=' + current.u_genesys_interaction_id);
    inteGR.addQuery('assigned_to', current.assigned_to);
    inteGR.query();

    if (inteGR.next()) {
        gs.addErrorMessage('A duplicate interaction with the same genesys ID and assignee already exists.');
        var url =gs.action.getGlideURI(inteGR);
        gs.info("url="+url);
        gs.setRedirect(inteGR);
        current.setAbortAction(true); // Abort the creation of the incident
        }
 
})(current, previous);
0 REPLIES 0