Giving me error as: {"code":"invalidDateFormat","message":"Invalid date format. Valid date format is
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 04:33 AM
Hi,
In pre processing script : I am taking current and past 3 days date and passing it in response body as shown in the SS
-------------------------------------------------
Giving me error as: {"code":"invalidDateFormat","message":"Invalid date format. Valid date format is YYYY-MM-DDThh:mm:ssZ."}
But if i give custom date it is working fine
Can you please help me here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 04:42 AM
what's the format you want to be sent to 3rd party?
Seems your output type for that variable is date/time but you are setting date/time in other format with timezone
Change the output type to String and run once
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 04:57 AM
given but still giving me error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 05:04 AM
use this and share logs
(function execute(inputs, outputs) {
var now = new GlideDateTime();
var threeDaysAgo = new GlideDateTime();
threeDaysAgo.addDaysUTC(-3); // Subtract 3 days
var dateTo = now.getValue().replace(' ', 'T') + 'Z';
outputs.updatedDateTo = dateTo;
var dateFrom = threeDaysAgo.getValue().replace(' ', 'T') + 'Z';
outputs.updatedDateFrom = dateFrom;
gs.info('date to' + dateTo + ' dateFrom ' + dateFrom);
})(inputs, outputs);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 05:47 AM
These are the logs date to2025-02-11T13:46:42Z dateFrom 2025-02-08T13:46:42Z