# SDK transfert data from gateway to perspective

**URL:** <https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349>\
**Category:** Module Development\
**Tags:** ignition80, perspective\
**Created:** [July 3, 2020, 5:27pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349 "2020-07-03T17:27:50Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 21, 2020, 3:53pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349/21 "2020-08-21T15:53:12Z")

</div>

You don’t restrict the `UserScopeMessageEvent` - you just drill down into the required event bus. From an `InternalSession`, you can either `findPage(<pageid>)` or `listPages()` - then if you want to send a page scoped event, use the page’s event bus: `getPageEventBus()`.

It looks like there’s no complementary function (that’s public) on `Page`, but sending a ‘View’ scope event would follow a similar model - you need to get to the View you want, then access its event bus.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [August 21, 2020, 4:10pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349/22 "2020-08-21T16:10:59Z")

</div>

Thanks a lot for these clarifications 👍

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 16, 2021, 1:09pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349/23 "2021-04-16T13:09:54Z")

</div>

Hi @paul-griffith

to obtain the sessionId

```auto
String sessionId = InternalSession.SESSION.get().getSession().getSessionId().toString();

```

work fine.

But if I need to obtain the pageId, I’ve tried:

```auto
String pageId = InternalSession.SESSION.get().getSession().getPage().getId().toString();

```

or

```auto
String pageId = InternalSession.SESSION.get().getPage().getId().toString();

```

But both of them are triggering a **java.lang.NullPointerException: null**

Did I missed something ?

I try to guess in a script function the sessionId and pageId to keep distinct data for multiple sessionId/pageId.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 16, 2021, 1:17pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349/24 "2021-04-16T13:17:46Z")

</div>

`getPage()` on a Session object will always return null. A Session may have multiple pages, so you may have to use `getPages()`, but I’m not sure if there is a way to know which page is open or whatever it is you are looking for.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 16, 2021, 1:32pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349/25 "2021-04-16T13:32:08Z")

</div>

Yes session have multiple page, but I try to obtain the “context” (sessionId,pageId) in a module script function.  
For sessionId,

```auto
String sessionId = InternalSession.SESSION.get().getSession().getSessionId().toString();

```

but to obtain the current pageId from where the script is executed, I don’t see ?

I want to avoid to pass the pageId parameter to each script function…

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 16, 2021, 2:34pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349/26 "2021-04-16T14:34:07Z")

</div>

Try `com.inductiveautomation.perspective.gateway.model.PageModel.PAGE.get()`.

Just a guess… I’m not very familiar with this area.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [April 16, 2021, 7:33pm UTC](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349/27 "2021-04-16T19:33:56Z")

</div>

That’s fine.  
👍

[Previous page](https://forum.inductiveautomation.com/t/sdk-transfert-data-from-gateway-to-perspective/36349.md?page=1)
