You are viewing the Resources for the older version of JourneyApps (V3). JourneyApps V4 is the new default for all new apps since July 1, 2016.

Accessing the Currently Enrolled User from JavaScript

You may often want to associate things with the current enrolled user in your app. For this purpose, JourneyApps provides a global user variable that you can access from any view's JavaScript.

For example, let's say we want to associate objects that a user creates in the mobile app with that particular user. If we have a form object that belongs to the user as shown below in our Data Model:

...then we can associate a new form (that we create in the init() function in one of our views) with the current user as follows, making use of the global user object: