GlideDateTime API in UI Builder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 06:57 AM
I'm new to UI Builder and still struggling with some concepts.
I want a Dropdown that contains the next 14 days. I thought the following script used in the Item panel would work, however, I don't get any results when click the Dropdown field.
function evaluateProperty({
api,
helpers
}) {
var dateArr = [];
var daysToInclude = 14;
var i = 0;
var body = {};
do {
var gdt = new GlideDateTime();
gdt.addDaysLocalTime(i)
body.id = 'date' + i;
body.label = gdt.getLocalDate().toString();
body.value = gdt.getLocalDate().toString();
var parsedJSON = JSON.stringify(body)
dateArr.push(parsedJSON);
i++;
} while (i < daysToInclude)
return ("[" + dateArr + "]");
}
In a background script, the output seems fine, and when the result is copy pasted into the JSON field in the 'Use static input' option, it renders fine. However, the script editor seems to suggest that using the GlideDateTime() API isn't valid:
Am I doing this right?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 09:22 AM
You need to create a Data Resource first. You can add one by clicking the +Add in the upper right corner:
Then go to your configuration field and type @. and you should get choices to pull from your data resources:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2022 02:56 AM
Hi Michael, I don't see how a Data Resource would help me. I'm not getting the data from anywhere. I just need the Dropdown populated with the next 14 dates. If this was the classic environment, I'd use the g_form.addOption and an array of dates to populate it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2022 05:22 AM
Oh, ok. If it's a dropdown, you can configure that in the desktop UI. That doesn't need to be done in UIB.