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

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.



 

Hi Sunil,

 

Thank you so very much for the information you provided.  It is a great start.  I probably won't get to experiment with this until sometime next week since we are preparing to upgrade our production instance to Yokohama this evening. I may have further questions for you down the road.

 

Thank you again!

Sunil B N
ServiceNow Employee
ServiceNow Employee

Hi Michele
Good luck with the Yokohama upgrade.
Just FYI - Latest version of CWM v6.0.3 is compatible with Y release.
And feel free to reach out to us anytime if questions come up.
Best regards,
Sunil B N

Hi Sunil,

 

I was able to experiment with this somewhat and created a space for a user from script. Then I was able to create a board in that space from a template and also create a doc in that space from a template using a script.

 

Some follow-on questions:

  • it is possible to create a folder with documents as a template and add that to a space? if not, can i create a folder using script and then add docs to that folder using templates in a script? it doesn't look like the CreateFromTemplate function allows you to specify a folder within a space.
  • can i control the order of items in the space i created?  i created a board from a template and then a doc from a template. when i look at the space, the doc appears first in the list followed by the board.

Thank you,

Michele