- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2015 09:16 AM
Hi,
I have been asked if there is a way to schedule (or an automatic procedure) a baseline in the project related lists?
I was thinking a kind of any specified date or time to have a 'snapshot' of the project tasks state and actual dates and progress.
I suggested scheduling reports, but it is not the same thing...
Thank you for any help,
Skender
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2015 05:08 AM
Change this line as per your requirement
projects.addEncodedQuery("active=true^state=1");
Baselines parent table is 'planned_task_baseline'. The script is for creation of baselines . You may run a scheduled report to automatically retrieve the data

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 05:34 AM
You can take a copy of the processing script of the ui page and use it as a base .. It is a simple gliderecord insertion and nothing complex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 08:09 AM
Kalai, could you give me more detailed info.
You mean put code like this to the script in the ui action?
function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
I looked at all the GlideRecord methods (on the right section),
but couldn't find anything which seemed like schedule (addActiveQuery()???)...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2015 12:10 PM
Will try to setup a demo as soon as I get some time tomorrow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2015 01:52 AM
This is a sample code for the baseline .. Paste and check in a scheduled job
(function () {
var baseline_name = '';
var projects = new GlideRecord("pm_project");
projects.addEncodedQuery("active=true^state=1");
projects.query();
while (projects.next()) {
var baseline = new GlideRecord("planned_task_baseline");
baseline.addQuery("top_task",projects.getValue('sys_id'));
baseline.query();
if(!baseline.next())
{
baseline_name = gs.now();
baseline.name = baseline_name.trim();
baseline.top_task = projects.getValue('sys_id');
baseline.description = 'Baseline Created Using Job';
insertBaseLineItems(projects.getValue('sys_id'),baseline.insert());
}
}
function insertBaseLineItems(task_id,baseId)
{
var tasks = new GlideRecord("planned_task");
tasks.addQuery("top_task", task_id);
tasks.query();
while (tasks.next()) {
var baseItem = new GlideRecord("planned_task_baseline_item");
baseItem.baseline = baseId;
baseItem.task = tasks.getUniqueValue();
baseItem.start = tasks.start_date;
baseItem.end = tasks.end_date;
baseItem.insert();
}
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2015 02:51 AM
I inserted this code in a scheduled job and it is correct,
but where do I specify the Project name (or id) and where can i retrieve the baselines created automatically?
Thanks again Kalai,