Skip to content
← Back to activity

Immutable solution version

Query multiple tables with Servicenow Rest API and Powershell

Version 1

Complete solution

Depends on what direction your join is (target parent, reference child vs target child, reference parent) If you're dot-walking through reference fields on the target table, you can just do it in the query like assigned_to.first_name=bob, and it will automatically join sc_task to sys_user on the assigned_to reference field.

[Joey (accepted answer)]: Depends on what direction your join is (target parent, reference child vs target child, reference parent) If you're dot-walking through reference fields on the target table, you can just do it in the query like assignedto.firstname=bob, and it will automatically join sctask to sysuser on the assignedto reference field. If you're not actually dot-walking, but rather looking to walk down into child records like if you were querying the problem table, but wanted to join a Related List like related incidents where the child incident table has a reference field named problemid pointing back up to your target problem table, you could create a Database view joining problem to incident on incident.problemid = problem.sysid, and name it something like problemincidents. Then, you can just treat that Database View like a table (as far as the REST API is concerned) like https://instance.service-now.com/api/now/table/problemincidents

Context: Stack Overflow #36988592 (accepted answer, 5 votes, 1 answers): Is there a way to search/join multiple tables within one URI/call using PowerShell? I'm trying to query the task table for any open TASK items and 'GET' back certain field values. The problem is that there are custom fields on the TASK item which are linked to other tables not on the TASK record/TASK table. `` URI $task = "https://instance.service-now.com/api/now/table/sc_task" Adding filters to the URI $task = "https://instance.service-now.com/api/now/table/sc_task?sysparm_query=yadadada" `` ..but I'm looking to be able to join multiple tables so I can "dot walk" to other tables other than

Evidence

Source: Stack Overflow #36988592 (accepted answer, 5 votes, 1 answers): Is there a way to search/join multiple tables within one URI/call using PowerShell? I'm trying to query the task table for any open TASK items and 'GET' back certain field values. The problem is that there are custom fields on the TASK item which are linked to other tables not on the TASK record/TASK table. `` URI $task = "https://instance.service-now.com/api/now/table/sc_task" Adding filters to the URI $task = "https://instance.service-now.com/api/now/table/sc_task?sysparm_query=yadadada" `` ..but I'm looking to be able to join multiple tables so I can "dot walk" to other tables other than

Verified resolution: [Joey (accepted answer)]: Depends on what direction your join is (target parent, reference child vs target child, reference parent) If you're dot-walking through reference fields on the target table, you can just do it in the query like assignedto.firstname=bob, and it will automatically join sctask to sysuser on the assignedto reference field. If you're not actually dot-walking, but rather looking to walk down into child records like if you were querying the problem table, but wanted to join a Related List like related incidents where the child incident table has a reference field named problemid pointing back up to your target problem table, you could create a Database view joining problem to incident on incident.problemid = problem.sysid, and name it something like problemincidents. Then, you can just treat that Database View like a table (as far as the REST API is concerned) like https://instance.service-now.com/api/now/table/problemincidents

Source URL: https://stackoverflow.com/questions/36988592

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_5St42tmA2uwTjHTWs6Qw3Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Query multiple tables with Servicenow Rest API and Powershell <span>— Vectle</span></a>

Query multiple tables with Servicenow Rest API and Powershell | Vectle