You are currently viewing Difference between getTableName and class name

Difference between getTableName and class name

Here’s a comparison between getTableName and class name in ServiceNow presented in a table format:

FeaturegetTableNameClass Name
PurposeRetrieves the name of the table associated with a GlideRecord object.Represents a JavaScript class defined within the ServiceNow platform’s scripting environment.
UsageCalled on a GlideRecord object to dynamically retrieve the table name.Used in server-side and client-side scripts to define and work with custom or predefined classes.
ScopeSpecifically used within server-side scripts such as Business Rules, Client Scripts, and Script Includes.It is used in a wide range of scripting scenarios, including business logic, data manipulation, and integration with external systems.
FunctionalityFacilitates object-oriented programming practices by encapsulating data and behaviour within reusable components.It provides a way to dynamically determine the table context in which a script executes.
Examplejavascript var tableName = current.getTableName();javascript class CustomClass { constructor(name) { this.name = name; } greet() { gs.info('Hello, ' + this.name + '!'); } } var obj = new CustomClass('John'); obj.greet();
ContextTypically used within scripts that interact with ServiceNow database tables and records.It provides a way to determine the table context in which a script executes dynamically.

This table provides a comparison between getTableName and class name in ServiceNow, highlighting their purposes, usage, scope, functionality, examples, and context within scripting environments.

Leave a Reply