CWM - questions on creating a space automatically

mah1
Kilo Sage

Yokohama

 

Would like to know if the following is possible...

 

When a new IT person is added, we want to automatically create a new space named 'Welcome to IT!' in CWM for that person then apply several templates to that space. These templates would add various documents and tasks to the Welcome to IT! space for the new IT person which will familiarize them with standard operating procedures and requirements.

 

Is it possible to do this using a script or flow?  What tables are involved? Where are spaces stored for a user? I looked at the sn_cwm_space table but that doesn't seem to list spaces created by users.

 

Thank you!

1 ACCEPTED SOLUTION

Sunil B N
ServiceNow Employee
ServiceNow Employee

Hi Michele,


This is great use case for whole Space to be saved as template. This is in our future roadmap.

Nevertheless, Currently this is feasible with Flows and scripting.
Steps:
1. Creation of Board template for tasks

2. Creation of Doc template with multiple pages for on boarding of the user.

3. Creation of Space. This step also automatically creates permission(sn_cwm_persmission) for the user to access that table

4. Creation of new Board using the Board template from step 1

5. Creation of new Doc using the Doc template from step 2.

Technical details:
a. Use new space as CWM user and create required Board and Doc template. Keep track of sys_ids. You can take a look in the table `
sn_cwm_template`
b. Create a new flow to trigger when new `sys_user` under `IT` Department is created then create a new Space.
table: sn_cwm_space.
c. Using `
sn_cwm.CWMTemplateService` script API, use `createFromTemplate: function(templateId, type, sourceId, sourceType, additionalParams)`  

templateId : sysId of template from Step a.
type: "doc"/"board"
sourceId:  space sys id from previous Step b.
sourceType: "space"
additionalParams: json as below
{
sourceTable: 'sn_cwm_template',
label: 'Doc or Board name',
triggerPoint: 'cwm_create_button', //required for doc 
docId: '-1', //required for doc 
}

This will create records mainly sn_cwm_board, sn_cwm_menu_item, sn_cwm_doc, sn_cwm_doc_page, sn_cwm_doc_m2m.


Alternatively you can include in the personal space we create: take a look at 

sn_cwm.CWMNavigationAPI._getOrBuildPersonalSpaceGr().


Disclaimer: The APIs used may be subjected to change in the future releases.

Hopefully this would help to get started.

Please let us know if you have any further questions.



 

View solution in original post

15 REPLIES 15

Sunil B N
ServiceNow Employee
ServiceNow Employee

 

You can switch by clicking on the globe icon at the right top corner as show below. And then create a script include. 

SunilBN_0-1751985877881.png

 

 

Again, I apologize for my lack of understanding here but I'm not sure I follow. Create a script include to do what? To just call CWMFolderUtil()).createFolder to create a folder or do everything (create the space, create folder, create board from template, create doc from template, etc.) in the script include? 

 

Thank you

Sunil B N
ServiceNow Employee
ServiceNow Employee

You can use this script wherever you did the previous coding before.. Either in flow script or in independent script include.

Thank you for bearing with me. I managed to create a folder using a script.

 

Now once that folder is created, do I just pass the folder Id with sourceType as 'folder' to the createFromTemplate function?

 

Thank you again!

Sunil B N
ServiceNow Employee
ServiceNow Employee

Great! That's correct. Just remember that the most recently created item appears at the top, so please create them in that order.