Skip to content

Include inherited ServiceNow table fields in field lookup#2312

Open
ravikiranvm wants to merge 9 commits into
mainfrom
ops-4414
Open

Include inherited ServiceNow table fields in field lookup#2312
ravikiranvm wants to merge 9 commits into
mainfrom
ops-4414

Conversation

@ravikiranvm
Copy link
Copy Markdown
Contributor

@ravikiranvm ravikiranvm commented May 26, 2026

Fixes OPS-4414 and OPS-4431

Problem

I was not able to see some service now table fields like Description and Short Description. It was due to that these fields were inherited from parent tables and we were looking for only the fields defined in the given table.

ServiceNow doesn't have an endpoint to return all the table fields their UI shows. There is one undocumented endpoint that returns all table fields that are shown on ServiceNow UI /ui/meta/{table} . But it is not officially available in their docs.

The current PR approach is how people usually solve this problem. Look ServiceNow REST API: Get list of column names

Fix

  • Walk the ServiceNow sys_db_object table hierarchy (the table of all tables in SN) when loading dictionary fields
  • Merge inherited fields from parent tables so child tables (e.g. incident) expose fields like description
  • Deduplicate by element name, preferring the most specific table in the hierarchy

Walk the sys_db_object hierarchy and merge sys_dictionary entries so
child tables like incident expose parent table fields in dropdowns.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copilot AI review requested due to automatic review settings May 26, 2026 15:04
@linear
Copy link
Copy Markdown

linear Bot commented May 26, 2026

OPS-4414

OPS-4431

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ServiceNow dictionary field lookup to include inherited fields by walking the sys_db_object table inheritance chain, so child tables (e.g. incident) surface parent fields in mapping dropdowns.

Changes:

  • Add sys_db_object lookups to build a table hierarchy (child → parent → …).
  • Query sys_dictionary for all tables in that hierarchy and merge/deduplicate fields by element, preferring the most specific table.
  • Increase sys_dictionary fetch limit to accommodate the expanded query set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/openops/src/lib/servicenow/get-table-fields.ts Outdated
Comment thread packages/openops/src/lib/servicenow/get-table-fields.ts Outdated
@ravikiranvm ravikiranvm requested a review from MarceloRGonc May 27, 2026 09:40
const tables = await getServiceNowTables(auth as ServiceNowAuth, {
query: 'nameSTARTSWITHx_',
});
const tables = await getServiceNowTables(auth as ServiceNowAuth);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try {
tableNames = await getServiceNowTableHierarchy(auth, tableName);
} catch (error) {
tableNames = [tableName];
Copy link
Copy Markdown
Contributor Author

@ravikiranvm ravikiranvm May 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Marco is not sure yet of what table would we have permissions for.
So if the user doesn't have permission to the 'sys_db_object', we fall-back to the original approach.

fieldName: Property.StaticDropdown<string>({
displayName: 'Field name',
description:
'Includes inherited fields from parent tables if your account has read access to sys_db_object.',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to let user know if he is confused about the missing fields.

@ravikiranvm ravikiranvm marked this pull request as ready for review May 29, 2026 12:25
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants