Skip to content

Include inherited ServiceNow table fields in field lookup#2312

Merged
ravikiranvm merged 10 commits into
mainfrom
ops-4414
Jun 1, 2026
Merged

Include inherited ServiceNow table fields in field lookup#2312
ravikiranvm merged 10 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
ravikiranvm added a commit that referenced this pull request Jun 1, 2026
- Move getServiceNowChoiceValues / ServiceNowChoice from the ServiceNow
  block into @openops/common so it can be reused across packages.
  The blocks-level file is removed and its single consumer
  (create-field-value-property) now imports from @openops/common.
- Add getServiceNowStateFields, a helper that returns the columns on a
  given table (including parent-table columns) that are usable as a
  status field (choice or integer with a layered sys_choice list). This
  is needed by upcoming campaign features that let users pick which
  ServiceNow field to read ticket state from.

Stacked on top of #2312 because getServiceNowStateFields depends on the
parent-hierarchy walk added there.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ravikiranvm added a commit that referenced this pull request Jun 1, 2026
- Move getServiceNowChoiceValues / ServiceNowChoice from the ServiceNow
  block into @openops/common so it can be reused across packages.
  The blocks-level file is removed and its single consumer
  (create-field-value-property) now imports from @openops/common.
- Add getServiceNowStateFields, a helper that returns the columns on a
  given table (including parent-table columns) that are usable as a
  status field (choice or integer with a layered sys_choice list). This
  is needed by upcoming campaign features that let users pick which
  ServiceNow field to read ticket state from.

Stacked on top of #2312 because getServiceNowStateFields depends on the
parent-hierarchy walk added there.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

@ravikiranvm ravikiranvm merged commit 2c80c35 into main Jun 1, 2026
22 checks passed
@ravikiranvm ravikiranvm deleted the ops-4414 branch June 1, 2026 11:32
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