0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

You can bulk update on the list screen for kintone

Posted at

スクリーンショット 2023-05-13 4.39.43.png

You can check all by pressing the CheckON button.

First,Display only Ethan

スクリーンショット 2023-05-13 4.40.43.png

Only Ethan was displayed.

スクリーンショット 2023-05-13 4.42.11.png

press the CheckON button please.

スクリーンショット 2023-05-13 5.43.47.png
スクリーンショット 2023-05-13 4.37.58.png

Only Ethan was checked.

Next, Let's remove the check.

スクリーンショット 2023-05-13 6.02.35.png

press the CheckOFF button to remove the check.

スクリーンショット 2023-05-13 4.30.58.png

unchecked all

JavaScript
(function() {
  'use strict';
  const getquery = function() {
    const appNo = kintone.app.getId()
    const OnBtnUpdate = document.createElement('button');
    OnBtnUpdate.innerText = 'CheckON';
    OnBtnUpdate.id = 'ONDateButton';

    const OFFBtnUpdate = document.createElement('button');
    OFFBtnUpdate.innerText = 'CheckOFF';
    OFFBtnUpdate.id = 'OFFDateButton';

    // ボタン増殖防止
    if (document.getElementById('ONDateButton') !== null) {
      return;
    }
    // ボタン増殖防止
    if (document.getElementById('OFFDateButton') !== null) {
      return;
    }

    // 絞り込み条件取得
    const queryCondition = kintone.app.getQueryCondition();

    // ONボタンクリック後の処理
    OnBtnUpdate.onclick = function() {
      const client = new KintoneRestAPIClient();
      const getnoparams = {
        app: appNo,
        query: '' + queryCondition + '',
        fields: ['$id', 'checkBox']
      };

      const checkOnRecords = [];

      client.record.getAllRecordsWithCursor(getnoparams).then((resp) => {

        // レコードの数でループ
        for (let i = 0; i < resp.length; i++) {
          checkOnRecords[i] = {
            'id': resp[i].$id.value,
            'record': {
              'checkBox': {
                'value': ['checked']
              }
            }
          };
        }
        const putrecords = {
          app: appNo,
          records: checkOnRecords
        };

        client.record.updateAllRecords(putrecords).then(() => {
          alert('Put a check mark ');
          location.reload();
        }).catch((error) => {
          alert('miss');
        });
      });
    };

    // OFFボタンクリック後の処理
    OFFBtnUpdate.onclick = function() {
      const client = new KintoneRestAPIClient();
      const getnoparams = {
        app: appNo,
        query: '' + queryCondition + '',
        fields: ['$id', 'checkBox']
      };

      const checkOffRecords = [];

      client.record.getAllRecordsWithCursor(getnoparams).then((resp) => {

        // レコードの数でループ
        for (let i = 0; i < resp.length; i++) {
          checkOffRecords[i] = {
            'id': resp[i].$id.value,
            'record': {
              'checkBox': {
                'value': []
              }
            }
          };
        }
        const putrecords = {
          app: appNo,
          records: checkOffRecords
        };

        client.record.updateAllRecords(putrecords).then((resp2) => {
          alert('uncheck all');
          location.reload();
        }).catch((error) => {
          alert('miss');
        });
      });
    };
    // ボタン設置
    kintone.app.getHeaderMenuSpaceElement().appendChild(OnBtnUpdate);
    kintone.app.getHeaderMenuSpaceElement().appendChild(OFFBtnUpdate);
  }
  const eventlist = [
    'app.record.index.show'
  ];
  kintone.events.on(eventlist, getquery);

If you want to use this kaind of functionality, it usually costs money. but This program is free :)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?