Modify CWM apply template procedure

E di Santo
Tera Contributor

Dear all,

I'm using Collaborative Work Management and would like to modify the Apply template functionality; this action just creates the list of saved tasks (of my starting template) but doesn't applies also relationships and some other fields I would need to set.

Does anybody know how to intercept this action and change it in order to add all other information?

 

Thanks in advance

1 ACCEPTED SOLUTION

Sunil B N
ServiceNow Employee

Hi Ernesto,

Could you elaborate what kind of data you would to store/apply as a part of template.
relationships - do you mean parent/child or other fields?
We usually save any field info which is the view while creating template.
Script Includes -  
CWMSaveTemplateUtil, CWMApplyBoardTemplateAPI predominately take care of Saving as a template and Creating from a template respectively.


Let me know if you have more questions.
Thanks and Regards,
Sunil B N



View solution in original post

8 REPLIES 8

Sunil B N
ServiceNow Employee

Hi Ernesto,
Thanks for sharing the details. There is no property or quick solution to this. You may beed to store this as additional information while saving as template in tasks JSON. and while applying use that additional information and create the relationships.. Post creation we have to 1:1 mapping b/w newly created task id vs task id the template.

Using the same data, you need to create relationships post creation of tasks in those script includes.

Thanks and regards,
Sunil B N

Tanushree Maiti
Mega Patron

Hi @E di Santo 

 

Refer this Servicenow Documentation link:

Apply a template to existing Board or Doc in CWM 

Update a template in CWM 

 

Also check : https://www.youtube.com/watch?v=nfYHU1GOnok

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:
In Collaborative Work Management, using templates for Boards and Documents helps us standardize work across teams. Storing both board and document templates in one central location ensures that our teams stay consistent and efficient. In this video, we'll show how to create, apply, and manage ...

Hi Tanushree,

I already checked on official documentation, I know how to apply a template, my issue is that template doesn't save also relationships between tasks, which is my need.

 

Thanks

E di Santo
Tera Contributor

For everyone, I met the requirement with some small customisations.

First of all I created a custom field on sn_cwm_task table adding an origination task field (type string, it will contain the sys_id of template originating task), then CWMApplyBoardTemplateAPI script include, here I added some code in the _applyTemplateBoardTaskRecords function in order to get relationships of template origination task and then apply the same to the new created tasks.

Thanks again to @Sunil B N for giving me some hints on scripts used by ServiceNow when applying template!

 

Bye

Ernesto