Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2025 03:57 AM
Does someone has a script which is coping all the projects based on some filter from teamspace 1 to pm_project table?
It shall include most important related lists as well like project tasks and so on.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:05 AM
Hi @PetarK ,
try with this
(function() {
var sourceTeamSpace = 'teamspace_1'; // Modify this to your source TeamSpace identifier
var targetTeamSpace = 'teamspace_2'; // Modify this to your target TeamSpace identifier
// Get projects from the source teamspace
var projectGR = new GlideRecord('teamspace_project'); // Replace with the correct table name if different
projectGR.addQuery('teamspace', sourceTeamSpace);
projectGR.query();
while (projectGR.next()) {
// Create a new project record in the pm_project table
var newProjectGR = new GlideRecord('pm_project');
newProjectGR.initialize();
newProjectGR.name = projectGR.name;
newProjectGR.short_description = projectGR.short_description;
newProjectGR.teamspace = targetTeamSpace; // Set target teamspace
newProjectGR.start_date = projectGR.start_date;
newProjectGR.end_date = projectGR.end_date;
newProjectGR.insert();
// Copy related project tasks
var taskGR = new GlideRecord('pm_project_task');
taskGR.addQuery('project', projectGR.sys_id);
taskGR.query();
while (taskGR.next()) {
var newTaskGR = new GlideRecord('pm_project_task');
newTaskGR.initialize();
newTaskGR.project = newProjectGR.sys_id; // Link the task to the new project
newTaskGR.short_description = taskGR.short_description;
newTaskGR.due_date = taskGR.due_date;
newTaskGR.state = taskGR.state;
newTaskGR.insert();
}
// Add more related lists here as needed
}
})();
1 REPLY 1
Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 01:05 AM
Hi @PetarK ,
try with this
(function() {
var sourceTeamSpace = 'teamspace_1'; // Modify this to your source TeamSpace identifier
var targetTeamSpace = 'teamspace_2'; // Modify this to your target TeamSpace identifier
// Get projects from the source teamspace
var projectGR = new GlideRecord('teamspace_project'); // Replace with the correct table name if different
projectGR.addQuery('teamspace', sourceTeamSpace);
projectGR.query();
while (projectGR.next()) {
// Create a new project record in the pm_project table
var newProjectGR = new GlideRecord('pm_project');
newProjectGR.initialize();
newProjectGR.name = projectGR.name;
newProjectGR.short_description = projectGR.short_description;
newProjectGR.teamspace = targetTeamSpace; // Set target teamspace
newProjectGR.start_date = projectGR.start_date;
newProjectGR.end_date = projectGR.end_date;
newProjectGR.insert();
// Copy related project tasks
var taskGR = new GlideRecord('pm_project_task');
taskGR.addQuery('project', projectGR.sys_id);
taskGR.query();
while (taskGR.next()) {
var newTaskGR = new GlideRecord('pm_project_task');
newTaskGR.initialize();
newTaskGR.project = newProjectGR.sys_id; // Link the task to the new project
newTaskGR.short_description = taskGR.short_description;
newTaskGR.due_date = taskGR.due_date;
newTaskGR.state = taskGR.state;
newTaskGR.insert();
}
// Add more related lists here as needed
}
})();
