Check logged in user is belongs to anyone of these Department or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:31 AM - edited 07-21-2023 03:45 AM
Hi All I have these departments starting with IOT I need to check whether the logged-in user belongs to these departments or not if he belongs to any one of these departments we return the value true others wise false how we can achieve with client script and script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:37 AM
HI @Somasekhar6 ,
I trust you are doing great.
Please find below script include and client script
Script Include:
var DepartmentUtils = Class.create();
DepartmentUtils.prototype = {
initialize: function () {},
checkUserDepartment: function (userDepartment) {
var currentUserDepartment = gs.getUser().getDepartment().getDisplayValue();
return currentUserDepartment.startsWith('IOT');
},
type: 'DepartmentUtils'
};
Client Script ;
(function () {
var userDepartment = 'IOT'; // Replace this with the department you want to check
var departmentUtils = new DepartmentUtils();
var isUserInDepartment = departmentUtils.checkUserDepartment(userDepartment);
if (isUserInDepartment) {
// Perform actions when the user belongs to the specified department
// For example, display a message or trigger other functions.
// You can add your desired actions here.
gs.addInfoMessage('You belong to the IOT department.');
} else {
// Perform actions when the user does not belong to the specified department
// For example, display a different message or handle other scenarios.
// You can add your desired actions here.
gs.addInfoMessage('You do not belong to the IOT department.');
}
})();
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:56 AM
@Amit Gujarathi thanks for your solution here my scenario is bit different We have several departments starts with name IOT like IoT coe, IoT Operations, IOT security etc . In the catalog we have one field if logged-in user belongs to any one of these departments which are starting with IOT then we need to make that catalog item field available.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 04:05 AM
In this scenario you can use below script only and write in if of client script logic to show the field and in else to hide the same
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 04:41 AM
if it's client callable we need to use glide Ajax right @Amit Gujarathi
Could you please share the updated script for the same using Glide Ajax.