- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2018 04:12 AM
How to get field type on server side(business rule)?
Can anyone please suggest me inside for loop in place of "field name" what can be use so that i can get value of glideElement.
for(var x in current)
{
var glideElement = recObj.getElement("field name");
var descriptor = glideElement.getED();
var result = descriptor.getInternalType();
}
Solved! Go to Solution.
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2018 02:07 PM
Not sure what you are trying to do. It appears as if you want all field types on a given record. Looking at your script recObj is not defined, so I used current. I also found that the sys_meta field causes the glideElement.getED() method to not work. Taking those into account, here is a script that will give you the field names and types for each field in the current record:
var fArray = [];
for (var x in current) {
if (x != 'sys_meta') {
fArray.push(x);
}
}
for (var f = 0; f < fArray.length; f++) {
gs.print('Field: ' + fArray[f]);
var glideElement = current.getElement(fArray[f]);
var descriptor = glideElement.getED();
var result = descriptor.getInternalType();
gs.print('Type: ' + result);
}
Feel free to modify it for your use.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2018 02:46 PM
Hi, Tried this one working for me.
var recObj=new GlideRecord('incident');
recObj.query();
while(recObj.next()){
var glideElement = recObj.getElement("caller_id");
gs.print(glideElement.getDisplayValue());
}
for your query replace the field name with any field value.
Thanks,Naveen