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

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Carl,



Will this be a one time job to create task or is it needs to fit as part of some process.


If this is one time job then we can write a script and create tasks. Please let me know if I am missing something.


Once we have more details on this, we will be able to further help you


Thank you.



Initially thinking, I'd want to be able to use it (with modifications) any time we get an "all clubs" task.



This month it's "replace monitors", next month or quarter may be it's "perform manual IT Hardware inventory" or "replace payment readers".



But to answer the question, it's a one time creation per project



Get Outlook for iOS<https://aka.ms/o0ukef>


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Thanks Carl for the update.


Please refer to the script shared by Chuck. Adjust it and let us know if you are blocked.


Please refer below link on how you can execute this via background script or fix script.


Background Scripts — ServiceNow Elite


http://wiki.servicenow.com/index.php?title=Fix_Scripts