Read-only instance connector

ServiceNow connection

Connect the developer instance through a restricted endpoint so agents can verify capabilities without receiving broad table access.

Your ServiceNow instance

Customer-owned read-only connection

Ready to test

Approved endpoint

/api/x_256896_bashsyn_0/bashsync_instance_api/v1/snapshot

Secure connection

Sign in directly with ServiceNow. BashSync never receives your password.

Authentication happens on your ServiceNow instance using OAuth PKCE. No password or client secret is entered into BashSync.

BashSync AI

Generates use case specific discovery, requirements, recommendations, and architecture.

Unavailable

Checking BashSync AI availability…

No API key is required from your users. AI requests are handled securely by BashSync and remain subject to the usage limits below.

ServiceNow configuration

Complete these steps inside the PDI. Do not use your administrator account as the integration identity.

1

Create scoped app

Create an application named BashSync Connector with scope x_256896_bashsyn_0.

2

Create role

Add x_256896_bashsyn_0.reader and assign it only to a dedicated integration user.

3

Create REST resource

Create GET /instance/v1/snapshot and require the x_256896_bashsyn_0.reader role.

4

Configure OAuth

Use Public Client with PKCE and the registered BashSync callback URL.

Connector resources

Install two read only resources

Complete each card in ServiceNow. The script stays hidden until you need to inspect it.

1

Instance snapshot

VERSION 2.0UPDATE REQUIRED

Lets BashSync verify the release, required plugins, and approved tables.

Go to: All → System Web Services → Scripted REST APIs → BashSync Instance API → Resources → New

Name

Instance Snapshot

Version

2.0

HTTP method

GET

Relative path

/v1/snapshot

Required role

x_256896_bashsyn_0.reader
View script
(function process(request, response) {
  var VERSION = '2.0';
  var packs = [
    { key: 'itsm', label: 'IT Service Management', plugins: [], tables: ['incident','problem','change_request','task_sla'] },
    { key: 'grc', label: 'Integrated Risk Management', plugins: ['com.snc.grc','com.snc.policy_compliance','com.snc.risk','com.snc.audit'], tables: ['sn_compliance_policy','sn_compliance_control','sn_risk_risk','sn_audit_engagement','sn_grc_issue'] },
    { key: 'performance_analytics', label: 'Performance Analytics', plugins: ['com.snc.pa','com.snc.pa.premium'], tables: ['pa_indicators','pa_scores','pa_breakdowns'] },
    { key: 'spm', label: 'Strategic Portfolio Management', plugins: ['com.snc.spm','com.snc.demand_management'], tables: ['dmn_demand','pm_project','rm_story'] },
    { key: 'csm', label: 'Customer Service Management', plugins: ['com.sn_customerservice'], tables: ['sn_customerservice_case','customer_account'] },
    { key: 'hrsd', label: 'HR Service Delivery', plugins: ['com.sn_hr_core'], tables: ['sn_hr_core_case','sn_hr_core_profile'] },
    { key: 'secops', label: 'Security Operations', plugins: ['com.snc.security_operations'], tables: ['sn_si_incident','sn_sec_cmn_src'] },
    { key: 'vulnerability_response', label: 'Vulnerability Response', plugins: ['com.snc.vulnerability_response'], tables: ['sn_vul_vulnerable_item','sn_vul_vulnerability'] },
    { key: 'itom', label: 'IT Operations Management', plugins: ['com.snc.discovery','com.snc.service_mapping'], tables: ['cmdb_ci','discovery_status','svc_ci_assoc'] },
    { key: 'asset_management', label: 'Asset Management', plugins: ['com.snc.samp','com.sn_hamp'], tables: ['alm_asset','alm_hardware','samp_sw_entitlement'] },
    { key: 'service_catalog', label: 'Service Catalog and Flow Designer', plugins: ['com.glideapp.servicecatalog'], tables: ['sc_cat_item','sc_req_item','sys_hub_flow'] }
  ];
  var pluginStatus = {};
  var tableStatus = {};
  var pluginIds = [];
  var tableNames = [];
  function addUnique(list, value) { if (list.indexOf(value) < 0) list.push(value); }
  packs.forEach(function(pack) {
    pack.plugins.forEach(function(id) { addUnique(pluginIds, id); });
    pack.tables.forEach(function(name) { addUnique(tableNames, name); });
  });
  pluginIds.forEach(function(id) { pluginStatus[id] = GlidePluginManager.isActive(id); });
  tableNames.forEach(function(name) {
    var record = new GlideRecord('sys_db_object');
    record.addQuery('name', name);
    record.setLimit(1);
    record.query();
    tableStatus[name] = record.next();
  });
  var snapshot = {
    resource_version: VERSION,
    generated_at: new GlideDateTime().getDisplayValue(),
    instance: gs.getProperty('instance_name'),
    build_name: gs.getProperty('glide.buildname'),
    build_tag: gs.getProperty('glide.buildtag'),
    capabilities: pluginIds.map(function(id) { return { id: id, active: pluginStatus[id] }; }),
    tables: tableNames.map(function(name) { return { name: name, available: tableStatus[name] }; }),
    capability_packs: []
  };
  packs.forEach(function(pack) {
    var activePlugins = pack.plugins.filter(function(id) { return pluginStatus[id]; });
    var availableTables = pack.tables.filter(function(name) { return tableStatus[name]; });
    var status = 'not_available';
    if (activePlugins.length) status = 'verified_active';
    else if (pack.tables.length && availableTables.length === pack.tables.length) status = 'verified_available';
    else if (availableTables.length) status = 'partially_available';
    else if (pack.plugins.length) status = 'verified_inactive';
    snapshot.capability_packs.push({ key: pack.key, label: pack.label, status: status, active_plugins: activePlugins, available_tables: availableTables });
  });
  response.setStatus(200);
  response.setBody(snapshot);
})(request, response);
2

Ask your instance

VERSION 2.2UPDATE REQUIRED

Answers governed questions across incidents, problems, changes, requests, demands, and available GRC tables.

Go to: All → System Web Services → Scripted REST APIs → BashSync Instance API → Resources → New

Name

Ask Your Instance

Version

2.2

HTTP method

GET

Relative path

/v1/query

Required role

x_256896_bashsyn_0.reader
View script
(function process(request, response) {
  var VERSION = '2.2';
  var requiredRole = 'x_256896_bashsyn_0.reader';
  if (!gs.hasRole(requiredRole)) {
    response.setStatus(403);
    response.setBody({ error: 'Access denied' });
    return;
  }

  var intent = String(request.queryParams.intent || '');
  var term = String(request.queryParams.term || '').trim();
  var period = String(request.queryParams.period || '');
  var priority = String(request.queryParams.priority || '');
  var group = String(request.queryParams.group || '').trim();
  var unassigned = String(request.queryParams.unassigned || '') == 'true';
  var tables = { incidents: 'incident', problems: 'problem', changes: 'change_request', requests: 'sc_req_item', demands: 'dmn_demand', risks: 'sn_risk_risk', controls: 'sn_compliance_control', grc_issues: 'sn_grc_issue' };
  function tableExists(name) { var record = new GlideRecord('sys_db_object'); record.addQuery('name', name); record.setLimit(1); record.query(); return record.next(); }
  function available(key) { return tableExists(tables[key]); }
  function display(record, field) { return record.isValidField(field) ? String(record.getDisplayValue(field) || '') : ''; }
  function value(record, field) { return record.isValidField(field) ? String(record.getValue(field) || '') : ''; }
  function row(record, type) { return { number: value(record, 'number'), type: type, status: display(record, record.isValidField('priority') ? 'priority' : record.isValidField('risk') ? 'risk' : 'state'), short_description: value(record, 'short_description'), assignment_group: display(record, 'assignment_group'), assigned_to: display(record, 'assigned_to'), opened_at: display(record, record.isValidField('opened_at') ? 'opened_at' : record.isValidField('start_date') ? 'start_date' : 'sys_created_on') }; }
  function count(table, activeOnly, extraField, extraOperator, extraValue) { if (!tableExists(table)) return null; var aggregate = new GlideAggregate(table); aggregate.addAggregate('COUNT'); if (activeOnly && aggregate.isValidField('active')) aggregate.addQuery('active', true); if (extraField && aggregate.isValidField(extraField)) aggregate.addQuery(extraField, extraOperator, extraValue); aggregate.query(); return aggregate.next() ? (parseInt(aggregate.getAggregate('COUNT'), 10) || 0) : 0; }
  function list(table, type, filter) { if (!tableExists(table)) return null; var output = []; var record = new GlideRecord(table); if (record.isValidField('active')) record.addQuery('active', true); if (filter) filter(record); if (record.isValidField('opened_at')) record.orderByDesc('opened_at'); else record.orderByDesc('sys_created_on'); record.setLimit(100); record.query(); while (record.next()) output.push(row(record, type)); return output; }
  function applyIncidentFilters(record) {
    if (priority) record.addQuery('priority', priority);
    if (unassigned) record.addNullQuery('assigned_to');
    if (group) record.addQuery('assignment_group.name', group);
    if (period == 'today') record.addQuery('opened_at', '>=', gs.beginningOfToday());
    else if (period == 'yesterday') { record.addQuery('opened_at', '>=', gs.daysAgoStart(1)); record.addQuery('opened_at', '<=', gs.daysAgoEnd(1)); }
    else if (period == 'this_week') record.addQuery('opened_at', '>=', gs.beginningOfThisWeek());
    else if (period == 'last_7_days') record.addQuery('opened_at', '>=', gs.daysAgoStart(7));
    else if (period == 'this_month') record.addQuery('opened_at', '>=', gs.beginningOfThisMonth());
  }
  function filteredIncidentCount() { if (!tableExists(tables.incidents)) return null; var aggregate = new GlideAggregate(tables.incidents); aggregate.addAggregate('COUNT'); aggregate.addQuery('active', true); applyIncidentFilters(aggregate); aggregate.query(); return aggregate.next() ? (parseInt(aggregate.getAggregate('COUNT'), 10) || 0) : 0; }

  if (intent == 'capabilities') {
    var moduleAvailability = { incidents: available('incidents'), problems: available('problems'), changes: available('changes'), requests: available('requests'), demands: available('demands'), grc: available('risks') || available('controls') || available('grc_issues'), overview: true };
    response.setStatus(200);
    response.setBody({ resource_version: VERSION, modules: moduleAvailability, tables: { incident: moduleAvailability.incidents, problem: moduleAvailability.problems, change_request: moduleAvailability.changes, sc_req_item: moduleAvailability.requests, dmn_demand: moduleAvailability.demands, sn_risk_risk: available('risks'), sn_compliance_control: available('controls'), sn_grc_issue: available('grc_issues') } });
    return;
  }

  var allowed = ['incident_filtered_list','incident_filtered_count','incident_active_list','incident_critical_list','incident_critical_count','incident_description_count','incident_opened_month_count','incident_unassigned_list','incident_unassigned_count','incident_group_breakdown','incident_active_count','problem_active_list','problem_active_count','change_active_list','change_high_risk_list','change_high_risk_count','change_active_count','request_active_list','request_unassigned_list','request_unassigned_count','request_active_count','demand_active_list','demand_active_count','grc_risk_list','grc_risk_count','grc_control_list','grc_control_count','grc_issue_list','grc_issue_count','operational_summary'];
  var allowedPeriods = ['', 'today', 'yesterday', 'this_week', 'last_7_days', 'this_month'];
  if (allowed.indexOf(intent) < 0 || term.length > 80 || group.length > 80 || (priority && !/^[1-5]$/.test(priority)) || allowedPeriods.indexOf(period) < 0) { response.setStatus(400); response.setBody({ error: 'Query is outside the approved allowlist' }); return; }

  var result = { count: 0 };
  if (intent == 'incident_filtered_list') result = { records: list(tables.incidents, 'Incident', applyIncidentFilters) };
  else if (intent == 'incident_filtered_count') result = { count: filteredIncidentCount() };
  else if (intent == 'incident_active_list') result = { records: list(tables.incidents, 'Incident') };
  else if (intent == 'incident_critical_list') result = { records: list(tables.incidents, 'Incident', function(r) { r.addQuery('priority', '1'); }) };
  else if (intent == 'incident_unassigned_list') result = { records: list(tables.incidents, 'Incident', function(r) { r.addNullQuery('assigned_to'); }) };
  else if (intent == 'problem_active_list') result = { records: list(tables.problems, 'Problem') };
  else if (intent == 'change_active_list') result = { records: list(tables.changes, 'Change') };
  else if (intent == 'change_high_risk_list') result = { records: list(tables.changes, 'Change', function(r) { if (r.isValidField('risk')) r.addQuery('risk', '1'); }) };
  else if (intent == 'request_active_list') result = { records: list(tables.requests, 'Request') };
  else if (intent == 'request_unassigned_list') result = { records: list(tables.requests, 'Request', function(r) { r.addNullQuery('assigned_to'); }) };
  else if (intent == 'demand_active_list') result = { records: list(tables.demands, 'Demand') };
  else if (intent == 'grc_risk_list') result = { records: list(tables.risks, 'Risk') };
  else if (intent == 'grc_control_list') result = { records: list(tables.controls, 'Control') };
  else if (intent == 'grc_issue_list') result = { records: list(tables.grc_issues, 'GRC Issue') };
  else if (intent == 'incident_group_breakdown') {
    var groups = []; var groupCount = new GlideAggregate(tables.incidents); groupCount.addQuery('active', true); groupCount.addAggregate('COUNT'); groupCount.groupBy('assignment_group'); groupCount.query(); while (groupCount.next()) groups.push({ name: display(groupCount, 'assignment_group'), count: parseInt(groupCount.getAggregate('COUNT'), 10) || 0 }); groups.sort(function(a, b) { return b.count - a.count; }); result = { groups: groups.slice(0, 10) };
  } else if (intent == 'operational_summary') {
    result = { metrics: [{ label: 'Active incidents', count: count(tables.incidents, true), available: available('incidents') }, { label: 'Active problems', count: count(tables.problems, true), available: available('problems') }, { label: 'Active changes', count: count(tables.changes, true), available: available('changes') }, { label: 'Active requests', count: count(tables.requests, true), available: available('requests') }, { label: 'Active demands', count: count(tables.demands, true), available: available('demands') }] };
  } else {
    var countMap = { incident_active_count: [tables.incidents, true], incident_critical_count: [tables.incidents, true, 'priority', '=', '1'], incident_unassigned_count: [tables.incidents, true, 'assigned_to', 'ISEMPTY', ''], incident_description_count: [tables.incidents, false, 'description', 'CONTAINS', term], incident_opened_month_count: [tables.incidents, false, 'opened_at', '>=', gs.beginningOfThisMonth()], problem_active_count: [tables.problems, true], change_active_count: [tables.changes, true], change_high_risk_count: [tables.changes, true, 'risk', '=', '1'], request_active_count: [tables.requests, true], request_unassigned_count: [tables.requests, true, 'assigned_to', 'ISEMPTY', ''], demand_active_count: [tables.demands, true], grc_risk_count: [tables.risks, true], grc_control_count: [tables.controls, true], grc_issue_count: [tables.grc_issues, true] };
    var args = countMap[intent]; var total = count(args[0], args[1], args[2], args[3], args[4]);
    if (total === null) { response.setStatus(409); response.setBody({ error: 'The required ServiceNow table is not available in this instance.' }); return; }
    result = { count: total };
  }
  if (result.records === null || result.count === null) { response.setStatus(409); response.setBody({ error: 'The required ServiceNow table is not available in this instance.' }); return; }
  response.setStatus(200); response.setBody(result);
})(request, response);

Test the complete connection

Verifies authentication, the snapshot resource, and Ask Instance.

Capability Discovery 2.0 checks eleven governed product packs and their supporting tables. It returns metadata only and does not expose client records.

Delete BashSync data

Permanently removes your solutions, requirements, architecture, implementation plans, guided tests, usage history, audit history, and connection settings. This does not delete your ChatGPT or ServiceNow account.