script running three times : copy the transcript from the interaction table to HR case

chandan31
Tera Contributor

Hi All,

 

Table : interaction

when : after

action:update 

Condition :Transcript is not empty 

 

Advanced script : 

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

    // Add your code here
    var v_sys_id = current.sys_id;


    var v_interaction = new GlideRecord('interaction_related_record');
    v_interaction.addQuery('interaction', v_sys_id);
    v_interaction.addEncodedQuery('document_table!=sys_user');
    v_interaction.query();
    if (v_interaction.next()) {



        var v_case = new GlideRecord('sn_hr_core_case');
        v_case.addQuery('sys_id', v_interaction.document_id);
        //v_case.addEncodedQuery('short_descriptionISEMPTY');
        v_case.query();
        if (v_case.next()) {



           
            v_case.work_notes = "transcript: \n\n " + current.transcript;

        v_case.update();
        }

    }


})(current, previous);
 
 
While running this script there will be a 3 times copy the transcript from the interaction to Hr case table while the chat interaction chat .
 
 
This script is execute multiple times, can you suggest how to execute  only one time.
1 ACCEPTED SOLUTION

Danish Bhairag2
Tera Sage
Tera Sage

Hi @chandan31 ,

 

Can u try changing ur condition to Transcript changes instead of its not empty & then check please.

 

Thanks,

Danish

 

View solution in original post

3 REPLIES 3

Danish Bhairag2
Tera Sage
Tera Sage

Hi @chandan31 ,

 

Can u try changing ur condition to Transcript changes instead of its not empty & then check please.

 

Thanks,

Danish

 

Thank you , it is working .

@chandan31  Your Welcome. Happy Learning😀

 

Thanks,

Danish