catalog item displayed only during the first 5 days of each month
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 05:34 AM
I have a catalog item that should only be displayed to users in a group and on a certain date each month, for example, the first 5 days of each month. Using user criteria? Can someone help me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 05:41 AM
you can use advanced script in user criteria and add that in Available for related list
var today = new GlideDate();
var dayOfMonth = today.getDayOfMonthNoTZ();
answer = gs.getUser().isMemberOf('Group ABC') && dayOfMonth >= 1 && dayOfMonth <= 5;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 06:34 AM - edited ‎12-30-2024 06:35 AM
@Ankur Bawiskar I added the script as you said, but today is the 30th (it doesn't match the conditions) and you can still see the item in the portal...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 06:39 AM
try this
1) mark Match all checkbox as true
2) update script as this
var today = new GlideDateTime();
var dayOfMonth = today.getDayOfMonthUTC();
answer = dayOfMonth >= 1 && dayOfMonth <= 5;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-30-2024 06:56 AM
@Ankur Bawiskar I've done that, people who aren't members of the group aren't seeing the item and that's correct. But members still are... and they should only be within the period from the 1st to the 5th of the month...