Examples of function fields

Chad Wilhelm1
Tera Expert

Hello,

Does anyone have examples of function fields?   I would like to see how they work and what is the syntax of the function definition.

Thanks,

Chad

1 ACCEPTED SOLUTION

Bhojraj Dhakate
Tera Expert

Hi Chad,

Please find below thread it might help to solve your queries:

1. https://docs.servicenow.com/bundle/kingston-application-development/page/build/platform-functions/task/create-function-field.html

2. https://docs.servicenow.com/bundle/kingston-application-development/page/build/platform-functions/concept/platform-support-functions.html

3. https://docs.servicenow.com/bundle/kingston-release-notes/page/release-notes/servicenow-platform/platform-support-functions-rn.html

 

Thanks,

Bhojraj

View solution in original post

8 REPLIES 8

Bhojraj Dhakate
Tera Expert

Hi Chad,

Please find below thread it might help to solve your queries:

1. https://docs.servicenow.com/bundle/kingston-application-development/page/build/platform-functions/task/create-function-field.html

2. https://docs.servicenow.com/bundle/kingston-application-development/page/build/platform-functions/concept/platform-support-functions.html

3. https://docs.servicenow.com/bundle/kingston-release-notes/page/release-notes/servicenow-platform/platform-support-functions-rn.html

 

Thanks,

Bhojraj

@Bhojraj Dhakate Links now broken.  Could you perhaps post an update?  Than you.

Chad Wilhelm1
Tera Expert

Is the GlideDBFunctionBuilder built within the function definition or is that built in a Script Include and then called from the function definition?

var functionBuilder = new GlideDBFunctionBuilder();
var myAddingFunction = functionBuilder.add();
myAddingFunction = functionBuilder.field('order');
myAddingFunction = functionBuilder.field('priority');
myAddingFunction = functionBuilder.build();

Thanks,
Chad

James Fricker
Tera Guru

Unfortunately the documentation for GlideDBFunctionBuilder is very poor. In some places it is just plain wrong. Whoever wrote the documentation clearly does not understand the builder pattern. This how I use it...

var gr = new GlideRecord('incident');
gr.addActiveQuery();
gr.addQuery(new GlideDBFunctionBuilder().length().field('short_description').build(), '<', 8);
gr.query();
gs.print(gr.getRowCount());

The build() method just returns a String, so it can be completely bypassed like this...

var gr = new GlideRecord('incident');
gr.addActiveQuery();
gr.addQuery('glidefunction:length(short_description)', '<', 8);
gr.query();
gs.print(gr.getRowCount());

This can also be converted to an encoded query and also used in list queries.

eg

var gr = new GlideRecord('incident');
gr.addQuery('active=true^glidefunction:length(short_description)<8');
gr.query();
gs.print(gr.getRowCount());

or

https://dev12345.service-now.com/incident_list.do?sysparm_query=active%3Dtrue%5Eglidefunction%3Alength(short_description)%3C8