How to check current user is portal user in BootstrapModulesV2

Hi Community,

From "UsrPortalDashboardCSS" the code is working fine. Whatever css defined its applying everywhere in list/detail/edit views of CRM and Portal (globally).

In code under "BootstrapModulesV2" I'm checking if current user is portal user than only apply CSS. same logic is working fine on other pageV2 for example "AccountPageV2" but the problem is that, CSS only applying on Account Section.

Below code is not working on "BootstrapModulesV2" console log is also not showing output.

Any help will be highly appreciable.

Below is sample code from "BootstrapModulesV2"

define("BootstrapModulesV2", ["css!UsrPortalDashboardCSS"],
function() {
	return {
		methods: {
			init: function() {
				this.callParent(arguments);
				this.initializeCustomCSS();
			},
			initializeCustomCSS: function() {
				var CurrentUser = this.Terrasoft.isCurrentUserSsp();
 
				if(CurrentUser === true){
					this.console.log("Current User is portal user");
					Terrasoft.utils.dom.setAttributeToBody("CustomUIPortalUser", true);
				}
				else {
					this.console.log("Current User is not portal user");
					Terrasoft.utils.dom.setAttributeToBody("CustomUIPortalUser", false);
				}
			}
		}
 
	};
});

 

Like 0

Like

2 comments

Hello! 

You can try using the code from the article below, inserting "All portal users" in the role name. 
https://customerfx.com/article/determining-if-a-user-has-a-specific-role-in-bpmonline/

Dennis Hudson,

This code is also not working

Below is my code in custom "BootstrapModulesV2"

define("BootstrapModulesV2", ["css!UsrPortalDashboardCSS", "css!UsrCRMDashboardCSS"], function() {
	return {
		methods: {
			init: function() {
				this.callParent(arguments);
				this.getCurrentUserRolea();
			},
			getCurrentUserRolea: function() {
				// Check if the user is in the "Accounting" role
				// this could be any role name, for example "All employees"
				var roleName = "All portal users";
 
				// create the query for SysUserInRole 
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
					rootSchemaName: "SysUserInRole"
				});
				esq.addColumn("SysRole");
 
				// add filter for current user
				esq.filters.add("UserFilter", Terrasoft.createColumnFilterWithParameter(
					Terrasoft.ComparisonType.EQUAL, "SysUser", Terrasoft.SysValue.CURRENT_USER.value
				));
 
				// add filter for role name, joining to SysRole (which is where the name is stored)
				esq.filters.add("RoleFilter", Terrasoft.createColumnFilterWithParameter(
					Terrasoft.ComparisonType.EQUAL, "SysRole.Name", roleName
				));
				// now get the results
				esq.getEntityCollection(function(result) {
					if (!result.success || result.collection.getItems().length === 0) {
						// the user is *not* in the role 
						// do something here if needed
						Terrasoft.utils.dom.setAttributeToBody("CustomUIPortalUsera", true);
					}
					else {
						// the user *is* in the role
						// do whatever is needed here
						Terrasoft.utils.dom.setAttributeToBody("CustomUIPortalUsera", false);
					}
				}, this);
			}
		}
	};
});

 

Show all comments