- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2023 09:24 PM
I would like to perform processing only on fields of type "Date/Time". (server side script)
I am thinking of storing all fields in an array and processing them, and only making judgments and processing in the case of date/time fields.
Is there a way to get the field type?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2023 10:11 PM
Hi,
You can get the type in server-side code referring below script-
var grInc = new GlideRecord('incident');
grInc.query('priority', '1');
var field = grInc.getElement('sys_updated_on');
var ed = field.getED();
var isEdge = ed.getInternalType();
gs.info(isEdge);
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2023 09:42 PM
Hello @bonsai,
You can use the 'typeof()' method to determine the type of your specified field. Please refer to the below code snippet for the reference:
https://www.workingcode.in/question/typeof-operator-use-in-servicenow/
If the above answer resolve your issue, Please marked the answer as 'Accepted Solution' and also marked it as 'Helpful'.
Thank You!
Prathamesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2023 10:09 PM
Is it possible to know the type of the field ('internal_type' in the dictionary record) rather than the type of value to set in the field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-25-2023 10:11 PM
Hi,
You can get the type in server-side code referring below script-
var grInc = new GlideRecord('incident');
grInc.query('priority', '1');
var field = grInc.getElement('sys_updated_on');
var ed = field.getED();
var isEdge = ed.getInternalType();
gs.info(isEdge);
Thanks and Regards,
Saurabh Gupta