Date Formatting - transform script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 08:58 PM
2 questions
1) i need to check if the date coming thro import set is a Valid date ( not format but valid date by itself and not any string like N/a or tbd etc ) ?? there are couple of validations on the client side but something seems off in transform scripting when it comes to validation
2) 3 columns with Date on the imported excel is in the Same format.. one column seems ok when loaded but other two columns when imported fails with unable to format .... Is there a way i can convert the date that comes through to a format and load to target table without asking business to change their sheets??
any leads on both?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 09:14 PM
@Priya123 DateTime format works in Servicenow same like Excel so either you keep same date format while importing from Excel or use string field in Servicenow.
But when you use string field , then you have to use GlideDatetime API and have to set display value so it will take same as user imported.
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 10:06 PM
you need to know what's a valid format you are expecting customer to share in that excel such as dd-MM-yyyy or dd/MM/yyyy
Unless you finalize a format for all the 3 excel columns it would be difficult for you to handle it in transform map
If you don't agree the format then it might be possible that after some days customer changes the format again. In that case your script or logic will break
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