Implement user criteria using scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 06:57 PM
I am trying to control the display of catalog items on the portal screen.
I would like to display them only to users who meet the following conditions.
・The company information of the logged-in user must be A or B.
・If the logged-in user's company information is A, the specific column information (let's say C) is not empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 07:02 PM
Hi @Takumi Togashi ,
Can u give this code a try.
(function() {
// Get the current user's company and specific column value
var currentUserCompany = gs.getUser().getCompanyID(); // Assuming the user's company information is stored in the 'company' field
var specificColumnInfo = current.getValue('specific_column'); // Replace 'specific_column' with the actual field name
// Check conditions: Company is A or B, and if company is A, specific column is not empty
if ((currentUserCompany == 'A' || currentUserCompany == 'B') && (currentUserCompany != 'A' || specificColumnInfo)) {
return true; // Return true to make the catalog item visible
} else {
return false; // Return false to hide the catalog item
}
})();
Mark my answer helpful & accepted if it helps you resolve your query.
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 08:00 PM
Thank you for your response.
I tried but it did not seem to show up for users whose company is A and the particular column is not empty, nor for users whose company is B. I am not sure if this is due to the fact that the column is not empty or not.
I would like to confirm one point. I am aware that A and B will have SysIDs, is this correct?
if ((currentUserCompany == 'A' || currentUserCompany == 'B') && (currentUserCompany ! = 'A' || specificColumnInfo))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2023 09:51 PM