
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:19 PM
Hello. It's been a very long day. Can someone please help with this:
//This works.
var gdt = new GlideDateTime("2023-03-11 7:00:00");
gdt.addDaysUTC(1);
gs.addInfoMessage("First Value Displayed: " + gdt);
//This does NOT work.
myArbitraryFunction(gdt, "addDaysUTC", 1);
//This does NOT work.
myArbitraryFunction(gdt, addDaysUTC, 1);
//This does NOT work.
myArbitraryFunction(gdt, GlideDateTime.addDaysUTC, 1);
//This does NOT work.
myArbitraryFunction(gdt, GlideDateTime.prototype.addDaysUTC, 1);
function myArbitraryFunction(anyObject, anyFunction, anyParameter){
gs.addInfoMessage("Got Here.");
anyObject.anyFunction(anyParameter);
gs.addInfoMessage("Second Value Displayed: " + gdt);
}
I'm running this in session, server side, using the "Debug Now" button from a Scheduled Script Execution. Here is a Screenshot:
I looked on W3Schools and Stack Overflow, but I just cannot seem to understand the examples there.
How can I properly 1) modify my function and 2) properly CALL the function to get the date to increment.
Please help. Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:39 PM
Hi @G24,
Try this:
//This works.
var gdt = new GlideDateTime("2023-03-11 7:00:00");
gdt.addDaysUTC(1);
gs.addInfoMessage("First Value Displayed: " + gdt);
myArbitraryFunction(gdt, "addDaysUTC", 1);
function myArbitraryFunction(anyObject, anyFunction, anyParameter){
gs.addInfoMessage("Got Here.");
anyObject[anyFunction](anyParameter);
gs.addInfoMessage("Second Value Displayed: " + gdt);
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 01:39 PM
Hi @G24,
Try this:
//This works.
var gdt = new GlideDateTime("2023-03-11 7:00:00");
gdt.addDaysUTC(1);
gs.addInfoMessage("First Value Displayed: " + gdt);
myArbitraryFunction(gdt, "addDaysUTC", 1);
function myArbitraryFunction(anyObject, anyFunction, anyParameter){
gs.addInfoMessage("Got Here.");
anyObject[anyFunction](anyParameter);
gs.addInfoMessage("Second Value Displayed: " + gdt);
}
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 02:27 PM
@Peter Bodelier You are a gentleman and a scholar, Sir. You have made my day, and my week.
May your wit charm the ladies, and may the cards fall your way.