How to find type of field in servicenow using script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:47 PM
Hi All,
How to find type of field in servicenow using script?
Thanks & Regards
Prashant Kumar
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:51 PM
Hi Prashant,
You can query the sys_dictionary table. The type field of a given field will be there.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:53 PM
Btw... the name of the field where the type resides within the sys_dictionary table it's called internal_type
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2017 12:01 AM
Hi Berny,
Actually, i am not looking for this.
What i was trying is if any catalog item form is loaded and there is one Date type field, then i want to check that current form has date fields then i want to validate whether its having right format or not.
Can you please help me on this?
Thanks & Regards
Prashant Kumar
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.
********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect
Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2017 12:05 AM
Hi Prashant,
Here's the script for that:
var recObj = new GlideRecord('<table eg cmdb_ci_ip_address>');
var glideElement = recObj.getElement('field name eg ip_address');
var descriptor = glideElement.getED();
var internalType = descriptor.getInternalType();
gs.print(internalType);
You can also go through get Field Type in Client Script for the same
Hope this helps.
Regards,
Riyanka