Automated Project Task creation

carlh
Kilo Guru

Hello All,

It's been requested that I come up with a way to "set up" a project task list.

We have over 1000 Club Locations in North America and we have a project to replace Monitors.   I am looking for a way to create a task for each location so the manager doesn't have to sit and create a new task for each.

Initially, I just had my techs create a task for each location as they worked on it but that made reporting the progress of the project impossible.

Any ideas on how this can be done?   I can get more specific if needed but hoped the over all idea makes enough sense as I will want to do this for many of the projects that come up.

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Carl,



If it were me, I'd create them using a script. If it is a 1-1 relationship between locations and tasks, use your location list as a "template" to create tasks and relate them to the parent project record.



For example (untested)



var projectID = '(sys_id_of_parent_record)';


var loc = new GlideRecord('cmn_location');


// Additional query filters here to limit the records


loc.query();



while (loc.next()) {


      var ptask = new GlideRecord('pm_project_task');


        ptask.newRecord();


        ptask.short_description = 'Monitors for ' + loc.getDisplayValue();


        ptask.parent = projectID;


        ptask.insert();


}



Try this with a limited number of records (eg. add loc.setLimit(3); in the initial query) to ensure it works. I'm not sure I have the parent/child thing quite right.


View solution in original post

8 REPLIES 8

You could also turn this in to a scheduled job that you can run on demand.



Creating a Scheduled Job - ServiceNow Wiki


Chuck Tomasi
Tera Patron

Hi Carl,



If it were me, I'd create them using a script. If it is a 1-1 relationship between locations and tasks, use your location list as a "template" to create tasks and relate them to the parent project record.



For example (untested)



var projectID = '(sys_id_of_parent_record)';


var loc = new GlideRecord('cmn_location');


// Additional query filters here to limit the records


loc.query();



while (loc.next()) {


      var ptask = new GlideRecord('pm_project_task');


        ptask.newRecord();


        ptask.short_description = 'Monitors for ' + loc.getDisplayValue();


        ptask.parent = projectID;


        ptask.insert();


}



Try this with a limited number of records (eg. add loc.setLimit(3); in the initial query) to ensure it works. I'm not sure I have the parent/child thing quite right.


Chuck,



If we create a table that is named 'u_monitor_replacment' for our tasks and it is 1-1 relationship. What would be considered the parent project record?



Regards,



Orlando


I would have to assume that the parent would be the location table in this example?