Skip to content

Move ServiceNow choice values to shared and add state fields helper#2316

Merged
ravikiranvm merged 13 commits into
mainfrom
ops-4424
Jun 1, 2026
Merged

Move ServiceNow choice values to shared and add state fields helper#2316
ravikiranvm merged 13 commits into
mainfrom
ops-4424

Conversation

@ravikiranvm
Copy link
Copy Markdown
Contributor

@ravikiranvm ravikiranvm commented May 29, 2026

Moves getServiceNowChoiceValues from the ServiceNow block into @openops/common so it can be reused across packages, and adds getServiceNowStateFields a helper that returns the columns on a given table (including parent-table columns) usable as a status field.

Part of OPS-4424

ravikiranvm and others added 4 commits May 26, 2026 20:34
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>
@linear
Copy link
Copy Markdown

linear Bot commented May 29, 2026

OPS-4424

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 refactors ServiceNow helpers so they can be reused across packages by moving getServiceNowChoiceValues into @openops/common and adding a new getServiceNowStateFields helper to identify candidate “status” columns (including inherited fields).

Changes:

  • Added getServiceNowStateFields helper to return status-like fields from a ServiceNow table’s dictionary (including parent-table fields).
  • Moved/re-exposed getServiceNowChoiceValues from the ServiceNow block to @openops/common, updating downstream imports/mocks.
  • Updated @openops/common exports to include the new/relocated ServiceNow helpers.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/openops/src/lib/servicenow/get-state-fields.ts New helper to list status-like fields based on table dictionary metadata.
packages/openops/src/lib/servicenow/get-choice-values.ts Adjusted auth import for the shared choice-values helper living in @openops/common.
packages/openops/src/index.ts Re-exported the ServiceNow helpers from the @openops/common barrel.
packages/blocks/servicenow/src/lib/create-field-value-property.ts Updated to consume getServiceNowChoiceValues from @openops/common.
packages/blocks/servicenow/test/lib/create-field-value-property.test.ts Updated mocking strategy to mock getServiceNowChoiceValues from @openops/common.
packages/blocks/servicenow/test/lib/get-choice-values.test.ts Removed block-level tests for getServiceNowChoiceValues (needs replacement in @openops/common).

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

Comment thread packages/openops/src/lib/servicenow/get-state-fields.ts Outdated
Comment thread packages/openops/src/index.ts
- 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>
* `choice` flag is `'1'` (dropdown) or `'3'` (dropdown without --None--).
* `'2'` (suggestion) is excluded because it allows free-text values.
*/
export async function getServiceNowStateFields(
Copy link
Copy Markdown
Contributor Author

@ravikiranvm ravikiranvm Jun 1, 2026

Choose a reason for hiding this comment

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

We need this new function to let user pick a column in the table which will be used for mapping OpenOps opportunity state with ticket state in ServiceNow.

Screenshot 2026-06-01 at 2 53 51 PM

@ravikiranvm ravikiranvm requested a review from MarceloRGonc June 1, 2026 09:23
Base automatically changed from ops-4414 to main June 1, 2026 11:32
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 1, 2026

@ravikiranvm ravikiranvm merged commit f57fd84 into main Jun 1, 2026
21 checks passed
@ravikiranvm ravikiranvm deleted the ops-4424 branch June 1, 2026 11:50
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