Hello @ShantiBhattarai,
You can get all groups of Current User, check if a user is a member of a specific group and redirect to a corresponding form using the following code.
To redirect a user to the appropriate Form Set by priority, you need to create an array and check if the array stores the desired group name.
return web.currentUser.get()
.then(function(user){
return web.siteUsers.getById(user.Id).groups.get()
.then(function(groupsData){
var groups = [];
//Check if the user is a member of the desired groups and add them to the array
for (var i = 0; i < groupsData.length; i++) {
if(groupsData[i].Title == 'Site Owners') {
groups.push('Site Owners');
}
if(groupsData[i].Title == 'Group A') {
groups.push('Group A');
}
}
//Redirect to a Form Set if the user is a member of a group
if (groups.indexOf('Site Owners') > 0) {
return 'FormSetIdForSiteOwners';
}
else if (groups.indexOf('Group A') > 0) {
return 'FormSetIdForGroupA';
}
});
});