# モバイルのレコード追加/編集後のイベント処理について

**URL:** <https://community.cybozu.dev/t/topic/1835>\
**Category:** kintone 開発相談\
**Created:** [2014 年 8 月 19 日午前 10:49 UTC](https://community.cybozu.dev/t/topic/1835 "2014-08-19T10:49:59Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Legacy\_Account806](https://avatars.discourse-cdn.com/v4/letter/l/b5a626/32.png) [@Legacy\_Account806](https://community.cybozu.dev/u/Legacy_Account806)\
**Post date:** [2014 年 8 月 27 日午前 1:39 UTC](https://community.cybozu.dev/t/topic/1835/7 "2014-08-27T01:39:52Z")

</div>

リファラーでやろうとしたところ、どうもレコード詳細画面のURLが必ず返ってくるようで断念。。

ということでstorageを使って以下のようにして前画面の状態を取るようにしました。

```
var storage = sessionStorage; //セッションストレージの準備

 //レコード編集画面表示時の処理
kintone.events.on('mobile.app.record.edit.show',function (event) {
  if (typeof sessionStorage !== 'undefined') {
          storage.setItem('mode','edit');
  } else {
    alert("本ブラウザではWeb Storageが使えません");
  }
});

 //レコード追加画面表示時の処理
kintone.events.on('mobile.app.record.create.show',function (event) {
  if (typeof sessionStorage !== 'undefined') {
      storage.setItem('mode','create');
  } else {
    alert("本ブラウザではWeb Storageが使えません");
  }
});

```

そして、レコード詳細イベントでこんな感じで処理を分けました。

kintone.events.on(‘mobile.app.record.detail.show’,function (event) {  
var mode = storage.getItem(‘mode’);

```
if(mode === 'create'){ //追加画面から
     〜追加画面から遷移してきた時の処理〜
      storage.clear();
  }

  if(mode === 'edit'){ //変更画面から
     〜変更画面から遷移してきた時の処理
  }

  storage.clear();

```

});

これでとりあえずは動いてくれました。

---

_[View the full topic](https://community.cybozu.dev/t/topic/1835)._
