- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 01:51 AM
Hello,
I'm working on a catalog item which has a Multiple Choice Variable with 2 choices:
- Current Year
- Next Year
I would like to make the choices dynamic, for example today the choices would be -2022 and -2023, and on 01/01/2023 choices would become -2023 and -2024.
I didn't find information on that, and I would like to know if this is possible to do ?
Thank you very much in advance for your feedback.
Kr,
Sylvain
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 05:36 AM
If I understood correctly, you would like to show current year and next year value in drop down option in catalog item variable. If so please use below script :
Create On Load Catalog Client script:
var currentYear=new Date().getFullYear();
var nextYear=currentYear+1;
g_form.addOption('yourFieldNameHere', currentYear, currentYear,1);
g_form.addOption('yourFieldNameHere', nextYear, nextYear,1);
Please mark answer as Correct or Helpful based on impact.
Regards,
Abhijit
ServiceNow MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2022 07:13 AM
Hello Abhijit,
Just tried it, works perfectly !
Thank you very much for your support !
Sylvain