Session

Overview

This is an object for properties related to the current session in the client UI. Session properties include the current user signed into the app and the app's chosen design theme.

  • From version: 2020.20

Properties

currentUser

currentUser: Contact

The user that is currently using the Workflow app. Use this to indicate which actions and elements should be available in the view and for displaying relevant data for the current user.

if(workflowApi.session.currentUser.id !== workflowApi.currentThread.createdBy.id){
 console.log("Enable/Disable things for the current users that did not created the current thread");
}

rolesIds

rolesIds: string[]

The current user roles Ids Use this to indicate which actions and elements should be available in the view and for displaying relevant data by users roles

const currentUserRolesIds = workflowApi.session.rolesIds;
const userRoles = workflowApi.utilities.getUsersAndRoles().filter((contact) => {
	currentUserRolesIds.indexOf(contact.id) !== -1 ))
});

theme

theme: ThemeType

The Workflow's design theme can be either a "Dark Mode" or "Light Mode" "ThemeType" is Used to indicate between the Theme types in the app.

if(workflowApi.session.theme === workflowApi.enums.ThemeType.Dark) {
	console.log("You can change your design here, so it will be specially adapted to Dark theme");
}