Script is not excute multiple times on change Script

chandan31
Tera Contributor

Hi ,

 

I have written on change client script but it is not working multiple time "it is excute  only two times:

 

 

and also Manadatory  is a problem and it is not excuting multiple time

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   var identifer_123 = g_form.getValue('current_shift_identifier');

         var wsOptions4 = 'BR';
        var wsOptions5 = 'VR';
        var wsOptions6 = 'SR';
        var wsOptions7 = 'VUF';
        var wsOptions_71 = 'VP';

        if ((identifer_123.startsWith(wsOptions4))) {
            g_form.removeOption('select_your_new_work_schedule', 'VRP10');
            g_form.removeOption('select_your_new_work_schedule', 'VRP20');
            g_form.removeOption('select_your_new_work_schedule', 'VRP30');
            g_form.removeOption('select_your_new_work_schedule', 'VRP40');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1A');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1B');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1C');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2A');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2B');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2D');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2E');
            g_form.removeOption('select_your_new_work_schedule', 'VPP1A');
g_form.setManadatory('select_your_new_work_schedule', true);
           

        }
        else if ((identifer_123.startsWith(wsOptions5))) {


            g_form.removeOption('select_your_new_work_schedule', 'BRP10');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3D');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3E');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4C');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1A');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1B');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1C');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2A');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2B');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2D');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2E');
            g_form.removeOption('select_your_new_work_schedule', 'VPP1A');


            g_form.addOption('select_your_new_work_schedule', 'VRP10','VRP10');
            g_form.addOption('select_your_new_work_schedule', 'VRP20','VRP20');
            g_form.addOption('select_your_new_work_schedule', 'VRP30','VRP30');
            g_form.addOption('select_your_new_work_schedule', 'VRP40','VRP40');
           
           



               



        }
        else if ((identifer_123.startsWith(wsOptions6))) {
            g_form.removeOption('select_your_new_work_schedule', 'BRP10');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3D');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3E');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4C');
            g_form.removeOption('select_your_new_work_schedule', 'VRP10');
            g_form.removeOption('select_your_new_work_schedule', 'VRP20');
            g_form.removeOption('select_your_new_work_schedule', 'VRP30');
            g_form.removeOption('select_your_new_work_schedule', 'VRP40');
            g_form.removeOption('select_your_new_work_schedule', 'VPP1A');




            g_form.addOption('select_your_new_work_schedule', 'SRP1A','SRP1A');
            g_form.addOption('select_your_new_work_schedule', 'SRP1B','SRP1B');
            g_form.addOption('select_your_new_work_schedule', 'SRP2A','SRP2A');
            g_form.addOption('select_your_new_work_schedule', 'SRP2B','SRP2B');
            g_form.addOption('select_your_new_work_schedule', 'SRP2C','SRP2C');
            g_form.addOption('select_your_new_work_schedule', 'SRP2D','SRP2D');
            g_form.addOption('select_your_new_work_schedule', 'SRP2E','SRP2E');
 
 
g_form.setManadatory('select_your_new_work_schedule', true);
           

        }
        else if ((identifer_123.startsWith(wsOptions7)) || (identifer_123.startsWith(wsOptions_71))) {
            g_form.removeOption('select_your_new_work_schedule', 'BRP10');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3D');
            g_form.removeOption('select_your_new_work_schedule', 'BRP3E');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4A');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4B');
            g_form.removeOption('select_your_new_work_schedule', 'BRP4C');
            g_form.removeOption('select_your_new_work_schedule', 'VRP10');
            g_form.removeOption('select_your_new_work_schedule', 'VRP20');
            g_form.removeOption('select_your_new_work_schedule', 'VRP30');
            g_form.removeOption('select_your_new_work_schedule', 'VRP40');
           
            g_form.removeOption('select_your_new_work_schedule', 'SRP1A');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1B');
            g_form.removeOption('select_your_new_work_schedule', 'SRP1C');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2A');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2B');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2C');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2D');
            g_form.removeOption('select_your_new_work_schedule', 'SRP2E');


             g_form.addOption('select_your_new_work_schedule', 'VPP1A','VPP1A');
               g_form.setManadatory('select_your_new_work_schedule', true);
             
        } else
            g_form.setVisible('select_your_new_work_schedule', false);

   //Type appropriate comment here, and begin script below
   
}
3 REPLIES 3

Bert_c1
Kilo Patron

Post a screen shot of the Client Script definition showing Table and Field name. Why would you expect it to run twice?

This is the hr service ,and field name current shift identifier

chandan31_0-1698851713050.png