Update Views

Updates the View settings of an App.

This API updates the pre-live settings.
After using this API, use the Deploy App Settings API to deploy the settings to the live App.

MethodPUT
URLhttps://{subdomain}.kintone.com/k/v1/preview/app/views.json
URL(guest space)https://{subdomain}.kintone.com/k/guest/{SpaceID}/v1/preview/app/views.json
Authentication Password Authentication, API Token Authentication, Session Authentication
Content-Typeapplication/json

Contents

Permissions

List/Calendar View:

  • App Management Permissions are needed.

Customize View:

  • Kintone Administrator Permissions are needed.
  • API Tokens cannot be used with this API.

Request Parameters

This API will replace all current Views with the Views listed in the request.
View names that are not stated in the request will be deleted.

Parameter Value Required Description
app Integer Yes The App ID.
views Object Yes An object of data of Views.
views.{viewname} Object Yes The View name of the View to add changes to.
If a View name that does exist is specified, a new View with this name will be created.
views.{viewname}.index String Yes The display order of the View, in the list of views, specified with a number. The list of views will be displayed in ascending order.
views.{viewname}.type String Yes The type of View.
  • LIST: List View
  • CALENDAR: Calendar View
  • CUSTOM: Custom View
views.{viewname}.name String Conditional The name of the View.
The maximum character limit is 64.
Required, if views.{viewname} is a new View. In this case, specify the same new View name for this parameter.
views.{viewname}.fields Array Conditional Used for List Views.
The list of fields to be displayed in the list. Specify fields by their field codes.
This parameter is required, if adding a new List View.
views.{viewname}.date String Used for Calendar Views.
The field to be used as the "Date Field" of the Calendar View.
Specify a date type field by their field code.
If ignored, the Created datetime field will be set.
views.{viewname}.title String Used for Calendar views.
The field to be used as the "Title Field" of the Calendar View.
Specify a text type field by their fieldcode.
If ignored, the Record number field will be set.
views.{viewname}.html String Used for Custom Views.
The HTML code to set for the Custom View.
views.{viewname}.pager Boolean The pagination settings. Specify one of the following:
  • true: Enable (default)
  • false: Disable
views.{viewname}.device String The scope of where the view is displayed.
If this parameter is not specified, the default is DESKTOP. If view settings are updated without specifying this parameter, this parameter does not change.
  • DESKTOP: Display only on desktop
  • ANY: Display on both desktop and mobile
views.{viewname}.filterCond String The filter condition in a query format.
Check here for more data on query formats.
views.{viewname}.sort String The sort order in a query format.
Check here for more data on query formats.
revision Integer Specify the revision number of the settings that will be deployed.
The request will fail if the revision number is not the latest revision.
The revision will not be checked if this parameter is ignored, or -1 is specified.

Sample Request

JavaScript (using Kintone REST API Request)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Adding new views: "My List View", "My Calendar View"
// Updating existing views: "My Custom View", "(Assigned to me)"
// Any other views not mentioned will be deleted

var body = {
  'app': 1,
  'views': {
    'My List View': {
      'index': 0,
      'type': 'LIST',
      'name': 'My List View',
      'fields': [
        'Record_number',
        'Text_single_line'
      ],
      'filterCond': 'Updated_datetime > LAST_WEEK()',
      'sort': 'Record_number asc'
    },
    'My Calendar View': {
      'index': 1,
      'type': 'CALENDAR',
      'name': 'My Calendar View',
      'date': 'Updated_datetime',
      'title': 'Rich_text',
      'filterCond': '',
      'sort': 'Record_number asc'
    },
    'My Custom View': {
      'index': 2,
      'type': 'CUSTOM',
      'html': '<div>Custom View HTML</div>',
      'filterCond': 'Updated_datetime >= LAST_WEEK() and Updated_datetime <= TODAY()',
      'sort': 'Record_number asc'
    },
    '(Assigned to me)': {
      'index': 3,
      'type': 'LIST'
    }
  }
};

kintone.api(kintone.api.url('/k/v1/preview/app/views.json', true), 'PUT', body, function(resp) {
  // success
  console.log(resp);
}, function(error) {
  // error
  console.log(error);
});

XMLHttpRequest

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Adding new views: "My List View", "My Calendar View"
// Updating existing views: "My Custom View", "(Assigned to me)"
// Any other views not mentioned will be deleted

var url = 'https://{subdomain}.kintone.com/k/v1/preview/app/views.json';
var body = {
  'app': 1,
  'views': {
    'My List View': {
      'index': 0,
      'type': 'LIST',
      'name': 'My List View',
      'fields': [
        'Record_number',
        'Text_single_line'
      ],
      'filterCond': 'Updated_datetime > LAST_WEEK()',
      'sort': 'Record_number asc'
    },
    'My Calendar View': {
      'index': 1,
      'type': 'CALENDAR',
      'name': 'My Calendar View',
      'date': 'Updated_datetime',
      'title': 'Rich_text',
      'filterCond': '',
      'sort': 'Record_number asc'
    },
    'My Custom View': {
      'index': 2,
      'type': 'CUSTOM',
      'html': '<div>Custom View HTML</div>',
      'filterCond': 'Updated_datetime >= LAST_WEEK() and Updated_datetime <= TODAY()',
      'sort': 'Record_number asc'
    },
    '(Assigned to me)': {
      'index': 3,
      'type': 'LIST'
    }
  },
  // CSRF TOKEN: used for all APIs that have an HTTP method of POST, PUT and DELETE on Kintone.
  '__REQUEST_TOKEN__': kintone.getRequestToken()
};

var xhr = new XMLHttpRequest();
xhr.open('PUT', url);
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onload = function() {
  if (xhr.status === 200) {
    // success
    console.log(JSON.parse(xhr.responseText));
  } else {
    // error
    console.log(JSON.parse(xhr.responseText));
  }
};
xhr.send(JSON.stringify(body));

Response Parameters

Parameter Type Description
revision String The revision number of the App settings.
views Object An object containing data of the Views.
views.{viewname}.id String The View ID.

Sample Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
  "views": {
    "Calendar View1": {
      "id": "1320"
    },
    "View1": {
      "id": "1321"
    },
    "Custom View1": {
      "id": "1322"
    }
  },
  "revision": 2
}

Limitations

  • This API cannot be used to update View settings if there are multiple Views with the same name.
  • If the target App contains any Custom Views, this API cannot update the views if it's authenticated with API tokens, as System Administration (External link) is needed to update these settings.