Project Templates - Can you apply them with javascript?

pgiroux
Tera Contributor

Hi,

Just wondering if anyone has figured out how to apply project templates to a new project within a workflow.

Thanks,

Patrick.

1 ACCEPTED SOLUTION

pgiroux
Tera Contributor

Ended up figuring this one out.



Insert the project first:



var grProject = new GlideRecord('pm_project');


grProject.assigned_to = current.request.requested_for;


grProject.project_manager = current.request.requested_for.manager;


grProject.short_description = current.variables.u_projectName;


grProject.primary_portfolio = current.variables.u_portfolio;


grProject.description = current.variables.u_description;



var projectId = grProject.insert();



var templateId = "<template sysID here>"; //found under the templates section within projects



Then with the variables above, apply the template with a specific method found in the 'create_project' UI page:



GlideProjectTemplate.apply(templateId, projectId, <string for datetime>);


View solution in original post

1 REPLY 1

pgiroux
Tera Contributor

Ended up figuring this one out.



Insert the project first:



var grProject = new GlideRecord('pm_project');


grProject.assigned_to = current.request.requested_for;


grProject.project_manager = current.request.requested_for.manager;


grProject.short_description = current.variables.u_projectName;


grProject.primary_portfolio = current.variables.u_portfolio;


grProject.description = current.variables.u_description;



var projectId = grProject.insert();



var templateId = "<template sysID here>"; //found under the templates section within projects



Then with the variables above, apply the template with a specific method found in the 'create_project' UI page:



GlideProjectTemplate.apply(templateId, projectId, <string for datetime>);