Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Import projects from xls into servicenow pm_project - how can we apply template for the import?

ashwinipingle
Tera Guru

Hello Developers/SPM experts,

I have around 200+ projects in an xls which I need to import in pm_project table. I am using the xls template provided by ServiceNow for this activity.

As we import the projects, I also want to apply templates to each project that is imported. This means that we also get the Gantt chart for each imported project and the user NEED NOT have to click and create this gantt chart.

Is it possible to do this in an import xls?

 

Best Regards,

Ashwini Pingle

2 REPLIES 2

sourav1999
Mega Guru

To import projects from an xls file into ServiceNow's pm_project and apply a template, follow these steps:

 

1. Prepare your xls file: Ensure that your xls file is properly formatted and contains all the necessary information for your projects. This includes fields like project name, start date, end date, project manager, etc.

 

2. Create a Data Source: In ServiceNow, navigate to System Import Sets > Administration > Data Sources and create a new data source. Choose "File" as the type and upload your xls file.

 

3. Create an Import Set Table: Navigate to System Import Sets > Administration > Import Sets and create a new import set. Choose the data source you just created.

 

4. Create Transform Map: Navigate to System Import Sets > Administration > Transform Maps. Create a new transform map and link it to the import set table you created. Here, you can define how the data from your xls file maps to the fields in the pm_project table.

 

5. Apply Template: If you have a project template that you want to apply to the imported projects, you can do this in the transform map. In the "onBefore" or "onAfter" script, you can use the applyTemplate() method of the Project API to apply your template to each project. Here is a sample code:

 

javascript

var project = new GlideRecord('pm_project');

project.get(source.u_project_id);

var template = new GlideRecord('pm_project_template');

template.get('template_sys_id'); // replace 'template_sys_id' with the sys_id of your template project.applyTemplate(template);

project.update();

 

6. Run the Import: Once your transform map is set up, you can run the import. Navigate to System Import Sets > Load Data and select your import set. Click on "Load Data" to start the import process.

 

7. Verify the Import: After the import is complete, navigate to Project > Projects to verify that your projects have been imported correctly and that the template has been applied.

 

Remember to test this process in a sub-production instance before applying it in production.

Hello @sumanta pal , @sourav1999 ,

I tried both your scripts in transform map, one at a time.

OnBefore and OnAfter both were tried.

The table name for templates is project_template (and not pm_project_template)

Following is the latest script i have

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
var gr = new GlideRecord('project_template');
gr.get('24f3dc361b73ad101336a6cee54bcb00');
// replace 'template_sys_id' with the sys_id of the template you want to apply
if (gr.isValid()) {
 target.applyTemplate(gr); }
})(source, map, log, target);
 
 
However I do not see a gantt chart after opening the project record and navigating to Planning Console from the related links. The gantt chart is not getting created in old or even in new Planning Console.
 
Best Regards,
Ashwini Pingle