eLabSDK2.System.Group

Hierarchy

Methods

getActiveGroupMembers

Static getActiveGroupMembers(): UserInterface[]

Get all users who are members of the currently active group.

This retrieves a list of all user accounts that belong to the current group context. Each user object contains comprehensive information including name, email, user ID, and other profile details. Use this to display group members, check permissions, or assign resources to users within the group.

Returns

UserInterface[]

An array of UserInterface objects, each representing a member of the active group.

Example

// List all group members
const members = eLabSDK2.System.Group.getActiveGroupMembers();
console.log(`Group has ${members.length} members:`);
members.forEach(user => {
  console.log(`- ${user.firstName} ${user.lastName} (${user.email})`);
});

Example

// Find a specific user in the group
const members = eLabSDK2.System.Group.getActiveGroupMembers();
const specificUser = members.find(user => user.email === '[email protected]');
if (specificUser) {
  console.log(`Found user: ${specificUser.firstName} ${specificUser.lastName}`);
}

Example

// Populate a user selector dropdown
const members = eLabSDK2.System.Group.getActiveGroupMembers();
const userOptions = members.map(user => ({
  value: user.userID,
  label: `${user.firstName} ${user.lastName}`
}));
populateDropdown(userSelector, userOptions);

Example

// Check if current user is admin in group
const members = eLabSDK2.System.Group.getActiveGroupMembers();
const currentUserId = eLabSDK2.System.User.getUserId();
const currentUser = members.find(u => u.userID === currentUserId);
const isAdmin = currentUser?.role === 'admin';

getActiveSubgroupId

Static getActiveSubgroupId(): number

Get the subgroup ID of the currently active group.

This retrieves the unique identifier for the currently active subgroup. Subgroup IDs are used throughout the API for filtering data, creating resources, and enforcing access control. Many API calls require a subgroup ID parameter to specify the context in which the operation should occur.

Returns

number

The numeric subgroup ID of the currently active group.

Example

// Get the current subgroup ID for an API call
const subgroupId = eLabSDK2.System.Group.getActiveSubgroupId();
const samples = await fetchSamples({ subgroupId: subgroupId });

Example

// Use subgroup ID when creating a new sample
const subgroupId = eLabSDK2.System.Group.getActiveSubgroupId();
const newSample = await api.createSample({
  name: 'My Sample',
  sampleTypeId: 5,
  subgroupId: subgroupId
});

Example

// Log current context
const subgroupId = eLabSDK2.System.Group.getActiveSubgroupId();
const groupInfo = eLabSDK2.System.Group.getGroup();
console.log(`Working in: ${groupInfo.activeGroup.name} (ID: ${subgroupId})`);

getGroup

Static getGroup(): GroupStoreInterface

Get the complete group state including active group information and members.

This retrieves comprehensive information about the current group context, including the active group details, subgroup information, and the list of users in the group. The returned object includes an extended activeGroup property with populated subGroups array for compatibility with components expecting this structure.

Returns

GroupStoreInterface

A GroupStoreInterface object containing usersInGroup (array of users) and activeGroup (current group details with subgroups).

Example

// Get current group information
const group = eLabSDK2.System.Group.getGroup();
console.log(`Active group: ${group.activeGroup.name}`);
console.log(`Subgroup ID: ${group.activeGroup.subGroupID}`);
console.log(`Members: ${group.usersInGroup.length}`);

Example

// Check if user is in the current group
const group = eLabSDK2.System.Group.getGroup();
const userId = eLabSDK2.System.User.getUserId();
const isInGroup = group.usersInGroup.some(user => user.userID === userId);
console.log(`Current user in group: ${isInGroup}`);

Example

// Display group information
const group = eLabSDK2.System.Group.getGroup();
console.log('Group Details:');
console.log(`- Name: ${group.activeGroup.name}`);
console.log(`- Subgroup ID: ${group.activeGroup.subGroupID}`);
console.log(`- Members:`);
group.usersInGroup.forEach(user => {
  console.log(`  - ${user.firstName} ${user.lastName}`);
});

© 2023 eLabNext