- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 11:20 AM
I have an Orchestration workflow that wants to see the AD user account expiration in a particular format, but not sure what microsoft is looking for...
I am doing this in my workflow:
var gdt = new GlideDateTime(expiry);
gdt.addDaysUTC(extend);
workflow.scratchpad.extend_date = gdt.getDate();
If I log/print the workflow.scratchpad.extend_date I can see "2019-02-01"
When I send this to AD to update the user accountExpires field it changes to: 1601-01-01
Is there a way to convert to microsoft time?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 02:18 PM
So after banging my head on the wall and then finding some code to do the reverse of what I want for Python (convert MS to UNIX) - I got this to work in my workflow...
Objective: Add days to AD accountExpires attribute to extend valid account dates.
//Calculate expires date
var gdt = new GlideDateTime(expiry);
gdt.addDaysUTC(extend);
//Here I convert GD to AD date
var gdt2 = new GlideDateTime(gdt);
var gdt_num = gdt.getNumericValue() * 10000;
var gdt_ms = gdt_num + 116444736000000000;
gdt2.setNumericValue(gdt_ms);
//
workflow.scratchpad.extend_date = gdt2.getNumericValue(); //pass to Orchestration
It can be cleaned up and made more efficient but this way shows it off better.
Next, I will probably try and create a script include and put it in dtUtils...If I get a chance 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2019 11:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 08:16 AM
It is helpful but I want to go in the other direction.
I may have to look at the dtutils script include.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 08:21 AM
Have you tried something like workflow.scratchpad.extend_date.getDisplayValue() ?
SN might be printing a user-friendly date when in the system, but passing along a value that might not be parseable by AD. The .getDisplayValue() should force the return of a string value that AD should be able to ingest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 10:37 AM
Thanks - I will try this.
I only tried .getNumericValue() so far.