catalog item displayed only during the first 5 days of each month

MariaVitorS
Tera Contributor

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?

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@MariaVitorS 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@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...
MariaVitorS_0-1735569141420.png

 

MariaVitorS_1-1735569156644.png

MariaVitorS_2-1735569255061.png

MariaVitorS_3-1735569275212.png

 

@MariaVitorS 

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.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@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...

MariaVitorS_0-1735570523657.pngMariaVitorS_1-1735570571221.png