[kintoone] Teams 알림 플러그인을 만들었어요.
                                            
                                                
                                                
                                                
                                                
                                                
                                                 16738 단어  HTMLJavaScriptkintonetech
                    
모티프
kintoone으로 팀 알림 플러그인을 만들었기 때문에 플러그인화해 보십시오.
규격.
kintoone 새 로그인 기록을 사용할 때 Teams에 알립니다.
프로젝트 작성
create-plugen을 사용하여 프로젝트 만들기
$ create-kintone-plugin プロジェクト名
  구성 화면 만들기
그림 완성
 코드
<section class="settings">
  <h2 class="settings-heading">プラグインの設定</h2>
  <p class="kintoneplugin-desc">teamsから取得したwebhookのURLを入力してください</p>
  <form class="js-submit-settings">
    <p class="kintoneplugin-row">
      <label for="message">
        URL:
        <input type="text" class="js-text-message kintoneplugin-input-text">
      </label>
    </p>
    <p class="kintoneplugin-row">
        <button type="button" class="js-cancel-button kintoneplugin-button-dialog-cancel">Cancel</button>
        <button class="kintoneplugin-button-dialog-ok">Save</button>
    </p>
  </form>
  설정 저장 및 불러오기
JQuery로 쓴 것을 원래의 JS로 바꾸었다.
코드
((PLUGIN_ID) => {
  'use strict';
  const form = document.querySelector('.js-submit-settings');
  const cancelButton = document.querySelector('.js-cancel-button');
  const url = document.querySelector('.js-text-message');
  const config = kintone.plugin.app.getConfig(PLUGIN_ID);
  console.log(form, cancelButton, url, config);
  if (config.url) {
    url.value = config.url;
  }
  form.addEventListener('submit', event => {
    event.preventDefault();
    kintone.plugin.app.setConfig({url: url.value}, () => {
      window.location.href = '../../flow?app=' + kintone.app.getId();
    });
  });
  cancelButton.addEventListener('click', () => {
    window.location.href = '../../' + kintone.app.getId() + '/plugin/';
  });
})(kintone.$PLUGIN_ID);
  응용 프로그램 사이드 프로세싱
레코드 저장 성공 이벤트를 트리거하여 Teams로 보냅니다.
팀스의 설정 방법을 따로 조사해 주세요.
코드
((PLUGIN_ID) => {
  'use strict';
  kintone.events.on('app.record.create.submit.success', (event) => {
    const config = kintone.plugin.app.getConfig(PLUGIN_ID);
    const webhookUrl = config.url;
    const payLoad = {
      'text': `新規レコードが追加されました。`
    };
    return new kintone.Promise((resolve, reject) => {
      kintone.proxy(webhookUrl, 'POST', {}, payLoad, (body, status, headers) => {
        resolve(event);
      });
    });
  });
})(kintone.$PLUGIN_ID);
  감상
플러그인 제작 방법을 대체로 파악했기 때문에 앞으로 알림 내용을 설정하려고 한다.
Reference
이 문제에 관하여([kintoone] Teams 알림 플러그인을 만들었어요.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/seruth/articles/a450d3bd7626f4텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)