Create a Guest Space from an App

Introduction

This article introduces a way to create a Guest Space with just a click of a button.

US_01.png


This customization comes in handy when you regularly need to create and manage Guest Spaces that have similar structure, threads and Apps. This solution replaces the trouble of manually creating a space from the portal and adding the necessary users and Apps inside every time.

This customization utilizes the Space Template feature of kintone. Create a Space Template in your kintone domain beforehand to work on the customization in this article.

Prepare the App

In this example, we will be using a kintone App to manage and create the Guest Spaces.
Create a new kintone App with the fields below:

Field Type Field Name Field Code
Text Guest Space Name GuestSpaceName
User Selection User Selection User_selection



Sample Code

Create a JavaScript file with the code below, and upload it to the App through the JavaScript and CSS customization settings.

Code Details

Creating the button

First, the below code creates a button on the record details page. This button will be used to create the new Guest Space.

 

Creating the request body for the API

The Add Space API has various parameters that can be set. In this article, we will set up just the minimum required parameters.

Parameters for creating a Space

  1. id
    The Space Template ID. Every Space Template has an ID associated with it. The Add Space API will create a Space based on the structure of this template.
    The Space Template ID is listed on the Space Templates list page, found under https://{domainname}.kintone.com/k/admin/system/spacetemplate/ .
  2. name
    The name given to the Space that will be created.
  3. isGuest
    "true" for Guest Spaces, "false" for Spaces that are not Guest Spaces. We will set this to "true" for this example.
  4. members
    kintone Users that will be added to the Space.

Refer to this page for more details on the parameters for the Add Space API..

 

Calling the API

Finally, the Add Space API is called.

 

US_02.png

Finally

The code in this article uses the values inside the Text field and the User selection field to create the parameters for the Add Space API. More parameters can be controlled in the App by placing more fields inside the kintone App, and relating them inside the code. Use the code in this article as reference, and set up the App and code that would best fit your purpose.

Was this article helpful?
0 out of 0 found this helpful
Comments
Please sign in to leave a comment.