- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 02:16 PM
Hi all. I'm frustrated after a couple of hours of trying to do something that I would normally consider simple.
I need a script to copy all of the dates from one field in the planned_task table to another. There is a field called start_date that is full of data (and only on the planned_task table) that I want to copy to the field called due_date (which is extended from the task table), because the previous administrator of the system created the start_date field to replace due_date for some reason, but I want to use due_date so it rolls up to the task table.
I am fine on the business rule side with updating this information as records are created/updated, but I need a script to go through the current records and copy all of this data to the proper field.
All help is always greatly appreciated!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 03:31 PM
Hi Dan,
You can copy below in your fix script and run fix script.
var ptask = new GlideRecord('planned_task');
ptask.addEncodedQuery('numberISNOTEMPTY');
ptask.query();
while(ptask.next()){
ptask.due_date = ptask.start_date;
ptask.update();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 02:41 PM
Hi,
You can develop fix script which will copy dates for current record.
You can reuse same script from your business rule in fix script.
You just need to replace current object to table glideojbect in fix script.
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 02:53 PM
Thanks for the reply, Sachin. I'm a low-coder, perhaps you could help me out because my business rule is very simple.
(function executeRule(current, previous /*null when async*/) {
current.due_date = current.start_date;
})(current, previous);
How would I translate this to a fix script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2017 03:31 PM
Hi Dan,
You can copy below in your fix script and run fix script.
var ptask = new GlideRecord('planned_task');
ptask.addEncodedQuery('numberISNOTEMPTY');
ptask.query();
while(ptask.next()){
ptask.due_date = ptask.start_date;
ptask.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2017 10:16 AM
This worked like a charm, I placed it into a scheduled weekly job and ran it initially and it populated the field in all records... now it'll just catch those that are missing the Start date going forward.