How to find type of field in servicenow using script?

PrashantLearnIT
Giga Sage

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
********************************************************************************************************
5 REPLIES 5

bernyalvarado
Mega Sage

Hi Prashant,



You can query the sys_dictionary table. The type field of a given field will be there.



Thanks,


Berny


bernyalvarado
Mega Sage

Btw... the name of the field where the type resides within the sys_dictionary table it's called internal_type



Thanks,


Berny


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
********************************************************************************************************

riyanka5
Kilo Expert

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