Background script (it should not create new records)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 09:03 PM
Hi! I'm having a hard time fixing this background script below. The script is working however, it creates new records in the vtb_task table. Am I missing something? Thank you in advance 🙂
var current = new GlideRecord('vtb_card');
current.query();
while (current.next()){
var vtbtask = new GlideRecord('vtb_task');
vtbtask.addQuery('sys_id', current.task);
vtbtask.query();
if (vtbtask.next()) {
vtbtask.setValue('u_choice_2', 'no');
} else {
vtbtask.setValue('u_choice_2', 'yes');
}
vtbtask.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 10:26 PM
Please use "card" or "vtbcard" instead of current variable and see if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 10:33 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 10:40 PM
Update line 5 as
card.task
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 10:44 PM
Hi @Aman Kumar S , it did not update the records. It only created new records.
Also the current.task pertains to the current task 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 10:47 PM
@ss123 ,
If you check your script, you are storing gliderecord reference in "Card" variable and now you are using current in 5th line, that's what throwing the error.
Aman Kumar