How to get field type on server side(business rule)?

Pallavi12
Tera Contributor

 

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();

}

1 ACCEPTED SOLUTION

ccajohnson
Kilo Sage

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.

View solution in original post

5 REPLIES 5

ccajohnson
Kilo Sage

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.

 

 

Could you also please let me know why there is a need to avoid 'sys_meta' in the query.

 

Thanks

 

Hi ,

 

Could you please also explain why there is a need to avoid "sys_meta".

 

Thanks

As I indicated before, it causes an error with one of the functions. Since I do not know why you need to iterate through all of the columns, it is unclear why you even need this. My guess is that is used to store the table and is not even a field you need to concern yourself with. It could be the collection column as is shown in the dictionary for Incident:

find_real_file.png