# プリントクリエイターの出力帳票制御に関して

**URL:** <https://community.cybozu.dev/t/topic/535>\
**Category:** kintone 開発相談\
**Created:** [2017 年 9 月 11 日午前 8:03 UTC](https://community.cybozu.dev/t/topic/535 "2017-09-11T08:03:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Legacy\_Account1598](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@Legacy\_Account1598](https://community.cybozu.dev/u/Legacy_Account1598)\
**Post date:** [2017 年 9 月 11 日午前 8:03 UTC](https://community.cybozu.dev/t/topic/535/1 "2017-09-11T08:03:07Z")

</div>

&nbsp;

&nbsp; 一つのアプリに複数の帳票を設定した場合、

&nbsp;

&nbsp;フォームの条件に従って出力できる帳票を制御することはできますか？

&nbsp;

&nbsp;例：Aアプリに 請求書（鑑）、請求書（明細）という２つの帳票を設定

&nbsp;

&nbsp;チェックボックス = ON&nbsp; → 請求書（鑑）のボタンのみ表示

&nbsp;

&nbsp;チェックボックス = OFF&nbsp;&nbsp; → 請求書（明細）のボタンのみ表示

&nbsp;

---

<div class="post-metadata">

**Author:** ![Legacy\_Account2115](https://avatars.discourse-cdn.com/v4/letter/l/e9bcb4/32.png) [@Legacy\_Account2115](https://community.cybozu.dev/u/Legacy_Account2115)\
**Post date:** [2017 年 9 月 12 日午前 1:59 UTC](https://community.cybozu.dev/t/topic/535/2 "2017-09-12T01:59:24Z")

</div>

hsoさん  
cstapの瀧ヶ平です。

プリントクリエイターの出力帳票の表示を制御する場合、プリントクリエイターの出力ボタンの表示を待ってから、当該のselect要素のDOMを操作することで可能です。  
表示を待つ処理はMutationObserverでDOMの変更を検知することで、select要素のDOMはdocument.querySelector(“select.pcreator-sheets-select”) で取得可能です。

今回の場合は以下のようなコードで実現できるかと思います。

```
(function() {"use strict";kintone.events.on("app.record.detail.show",function(event) {
    (newMutationObserver(function(\_,observer) {varselector=document.querySelector("select.pcreator-sheets-select");if(selector){varenableSheet=event.record["チェックボックス"].value?"請求書（鑑）":"請求書（明細）";Array.from(selector.options).forEach(function(option) {if(option.textContent!==enebleSheet)option.style.display="none";
        });observer.disconnect();
      }
    })).observe(kintone.app.record.getHeaderMenuSpaceElement(), {childList:true, subtree:true});returnevent;
  });
})();

```

参考になりますでしょうか

---

<div class="post-metadata">

**Author:** ![Legacy\_Account1074](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@Legacy\_Account1074](https://community.cybozu.dev/u/Legacy_Account1074)\
**Post date:** [2019 年 7 月 18 日午前 2:54 UTC](https://community.cybozu.dev/t/topic/535/3 "2019-07-18T02:54:37Z")

</div>

横から失礼します。

実装してみたのですが、常にチェックオンの場合の項目のみが表示されます。

何かコードが違うのでしょうか。
