The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Script Include Creating New Records

She Sull
Giga Guru

I am using a Script Include to filter Contract Types based on the User Department for Time tracking.   I have a Reference Qualifier on the Contract Type on the Time Entry form (we're not using the OOB Time Cards, instead we're using a Time Sheets custom app I found on Share). This worked fine before, but I had to modify the script. What's happening now is a new Contract Type record is being created whenever I enter a new Time Entry. Other than that it works as expected. Any suggestions?

 

Here's a snippet of the code to fill the contract type based on dept:

 

function u_fillContractType() {  

//contract type and dept variables

  var dept = current.user.department.getDisplayValue();

      var cntype = ' ';  

              if(!dept)  

                      return;

 

//is this my problem? i had this same line in the old script and didn't have a problem

              var nt = new GlideRecord('u_contract_type');

 

  //Display contract types based on depts

              if((dept=="XYZ") || (dept=="ABC") || (dept=="123") || (dept=="JKL")){nt.addQuery('u_contract_type','IN','Contract 1,Contract 2,Contract 3');}

 

  //Display diff contracts for this other dept

              else if(dept=="999"){nt.addQuery('u_contract_type','IN','Contract 1,Contract 2,Contract 3, Contract 4');}

 

//Default to Stratus

  else {nt.addQuery('u_contract_type','Stratus');}

 

//run through and return the appropriate contract types

              nt.query();  

              while(nt.next()) {  

                      if (cntype.length > 0) {  

                              cntype += (',' + nt.sys_id);  

                      }  

                      else {  

                              cntype = nt.sys_id;  

                      }  

              }  

              return 'sys_idIN' + cntype;

      }

//END

1 ACCEPTED SOLUTION

She Sull
Giga Guru

Kalaiarasan P, Jake Gillespie,



I figured it out....some of the contracts and task categories had more characters than the field was set-up for. For instance, Contract Type was set-up as a 32 char field, but I had one that was 33 chars. After I fixed this I am not getting any more "phantom" records!



I appreciate everyone's help on this as it got me thinking of multiple items that could be causing the issue.



Thanks,



- Sherry


View solution in original post

7 REPLIES 7

Thanks, Jake. I'll give that a try.



- Sherry


just a thought ...



She Sull
Giga Guru

Kalaiarasan P, Jake Gillespie,



I figured it out....some of the contracts and task categories had more characters than the field was set-up for. For instance, Contract Type was set-up as a 32 char field, but I had one that was 33 chars. After I fixed this I am not getting any more "phantom" records!



I appreciate everyone's help on this as it got me thinking of multiple items that could be causing the issue.



Thanks,



- Sherry