Project baseline - is there a way to schedule a baseline?

skendy
Tera Expert

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

1 ACCEPTED SOLUTION

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


View solution in original post

21 REPLIES 21

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  


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()???)...


Will try to setup a demo as soon as I get some time tomorrow


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();


              }


      }


     


})();


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,