Copying process management settings to another App

Introduction

This article introduces a JavaScript customization that creates a button to copy the process management settings from App A to App B utilizing the following APIs:

Completed customization image

A button to copy the Process Management settings is placed in the record list view of the Expense Report App. When the button is clicked, an alert dialog will be displayed, and the Process Management settings will be copied to the destination App.

copybutton.gif

 

The Process Management settings view of the destination App before copying.

US_07.png

 

The Process Management settings view of the destination App after copying. The Status Settings and Process Flow Settings now reflect those of the source App.

US_08.png

Preparing the Apps

Two Apps will need to be prepared. One will hold the Process Management settings to be copied, and one will be the destination App to copy the settings to. This tutorial will use the following Apps:

  • Expense Report App: This will be the copy source. The App can be created from the Kintone Marketplace.
  • New App: This will be the copy destination. This App will be made from scratch.

For help on how to create an App from the Kintone Marketplace, refer to the Creating an App from the Marketplace article in the Kintone Help Center. For help on how to create an App from scratch, refer to the How to Build an App article in the Kintone Help Center.

Copy Source: The Expense Report App

The following workflow is set automatically in the process management settings of the Expense Report App when it is created from the Kintone Marketplace.

Image of the workflow

US_01.png

Open the Process Management settings page in the Expense Report App and delete the "Approver" and "Employee" user fields from the Assignee List. This is necessary because an error will occur if fields that are not present in the copy destination App are included in the Process Management settings that are copied.

US_02.png

Copy destination: The New App

Fields do not need to be added to the New App, but be sure to enable the Process Management feature through the App settings, which will create the default workflow as below:

Image of the workflow

US_03.png

Customization

The code uses the following 4 steps to copy the Process Management settings of the Expense Report App and deploy them to the Process Management settings of the New App:

  1. Place a button in the list view of the Expense Report App to trigger the code
  2. Retrieve the Process Management settings from the Expense Report App
  3. Update the settings of the destination App (the New App) with the settings retrieved in step 2
  4. Apply the pre-live App settings of the destination App (the New App) to the live environment

1. Place a button in the list view of the Expense Report App to trigger the code

Refer to the Add Buttons (Record Details) article for details on how to place a button in the list view of an App. Take note of the App number of the destination app and assign it to the variable, "COPY_APPID". Steps 2-4 are processed with Promises when the button is clicked. Refer to the Using Promises with the Kintone API article for more information on using Promises.

2. Retrieve the Process Management settings from the Expense Report App

Refer to the Get Process Management Settings API documentation for details on how to retrieve the Process Management settings from an App.

 

3. Update the settings of the destination App (the New App) with the settings retrieved in step 2

Refer to the Update Process Management Settings API documentation for details on how to update the destination App, New App, with the settings retrieved in step 2.

 

4. Apply the pre-live App settings of the destination App (the New App) to the live environment

Step 3 updates the App settings, but these are not applied to the live environment until the Deploy App Settings API is used. Refer to the Deploy App Settings API Documentation for details on how to reflect the contents updated in step 3 onto an operational environment. 

The codes introduced in steps 1 through 4 above are compiled into the following full sample code.

Sample Code

 

Referenced Articles

Finally

This article introduced a customization example for copying the Process Management settings of one App and deploying them into another App. The button is very convenient when you need to re-use the same workflow in multiple use cases.

Was this article helpful?
0 out of 0 found this helpful
Do you have any questions or issues related to this article?
Please share your views with us in the Community forums!