
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2014 05:27 PM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2014 07:01 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-26-2014 06:26 PM
this is a query and will not insert any record... must be some piece somewhere else causing this......

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2014 10:56 PM
Hi Sherry,
As Kalaiarasan said, the script you posted is performing a query, and returning the resulting sys_id's in an encoded string format (commonly used for reference qualifiers).
I'm not familiar with the Timesheet application you're using, but if the Time Entries you're adding are records themselves, then I would check the Business Rules running on that table. It is likely that an insert/update BR is triggering the Contract Type record creation. The code doing the insert would either be in the BR itself, or in a Script Include called from the BR. I would suggest doing a "script contains" search for the table name in question (e.g u_contract_type .. if that's the table name for Contract Type) in the business rules.
Regards,
Jake

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2014 09:56 AM
Thanks, Jake Gillespie, but there are no business rules on the tables in question. It was definitely worth looking into though.
I'm still troubleshooting this issue.
Thanks,
- Sherry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2014 04:39 PM
Hi Sherry,
I recommend searching all Business Rules and Script Includes for the term "GlideRecord('u_contract_type')". If a script is performing the record insert on the "u_contract_type" table, then it would be using the above statement in the constructor line where the object is first instantiated. If you check all occurrences of this line being used, and one of them is followed by a ".insert()" for the same object, then you might find the script that is actually doing the record creation.
Regards,
Jake