Skip to content

Commit bb3aee3

Browse files
waleedlatif1claude
andcommitted
fix(trigger): add webhook secret field and remove non-TSDoc comment
Add webhookSecret field to ServiceNow triggers (matching Salesforce pattern) so users are prompted to protect the webhook endpoint. Update setup instructions to include Authorization header in the Business Rule example. Remove non-TSDoc inline comment in the block config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent baa3dcf commit bb3aee3

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

apps/sim/blocks/blocks/servicenow.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ Output: {"state": "2", "assigned_to": "john.doe", "work_notes": "Assigned and st
216216
condition: { field: 'operation', value: 'servicenow_delete_record' },
217217
required: true,
218218
},
219-
// Trigger SubBlocks
220219
...getTrigger('servicenow_incident_created').subBlocks,
221220
...getTrigger('servicenow_incident_updated').subBlocks,
222221
...getTrigger('servicenow_change_request_created').subBlocks,

apps/sim/triggers/servicenow/utils.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ export function servicenowSetupInstructions(eventType: string): string {
2222
'Navigate to <strong>System Definition > Business Rules</strong> and create a new Business Rule.',
2323
`Set the table (e.g., <strong>incident</strong>, <strong>change_request</strong>), set <strong>When</strong> to <strong>after</strong>, and check <strong>${eventType}</strong>.`,
2424
'Check the <strong>Advanced</strong> checkbox to enable the script editor.',
25-
`In the script, use <strong>RESTMessageV2</strong> to POST the record data as JSON to the <strong>Webhook URL</strong> above. Example:<br/><code style="font-size: 0.85em; display: block; margin-top: 4px; white-space: pre-wrap;">var r = new sn_ws.RESTMessageV2();\nr.setEndpoint("&lt;webhook_url&gt;");\nr.setHttpMethod("POST");\nr.setRequestHeader("Content-Type", "application/json");\nr.setRequestBody(JSON.stringify({\n sysId: current.sys_id.toString(),\n number: current.number.toString(),\n shortDescription: current.short_description.toString(),\n state: current.state.toString(),\n priority: current.priority.toString()\n}));\nr.execute();</code>`,
25+
'Copy the <strong>Webhook URL</strong> above and generate a <strong>Webhook Secret</strong> (any strong random string). Paste the secret in the <strong>Webhook Secret</strong> field here.',
26+
`In the script, use <strong>RESTMessageV2</strong> to POST the record data as JSON to the <strong>Webhook URL</strong> above. Include the secret as <code>Authorization: Bearer &lt;your secret&gt;</code> or <code>X-Sim-Webhook-Secret: &lt;your secret&gt;</code>. Example:<br/><code style="font-size: 0.85em; display: block; margin-top: 4px; white-space: pre-wrap;">var r = new sn_ws.RESTMessageV2();\nr.setEndpoint("&lt;webhook_url&gt;");\nr.setHttpMethod("POST");\nr.setRequestHeader("Content-Type", "application/json");\nr.setRequestHeader("Authorization", "Bearer &lt;your_webhook_secret&gt;");\nr.setRequestBody(JSON.stringify({\n sysId: current.sys_id.toString(),\n number: current.number.toString(),\n shortDescription: current.short_description.toString(),\n state: current.state.toString(),\n priority: current.priority.toString()\n}));\nr.execute();</code>`,
2627
'Activate the Business Rule and click "Save" above to activate your trigger.',
2728
]
2829

@@ -35,10 +36,29 @@ export function servicenowSetupInstructions(eventType: string): string {
3536
}
3637

3738
/**
38-
* Extra fields for ServiceNow triggers (optional table filter)
39+
* Webhook secret field for ServiceNow triggers
40+
*/
41+
function servicenowWebhookSecretField(triggerId: string): SubBlockConfig {
42+
return {
43+
id: 'webhookSecret',
44+
title: 'Webhook Secret',
45+
type: 'short-input',
46+
placeholder: 'Generate a secret and paste it here',
47+
description:
48+
'Required. Use the same value in your ServiceNow Business Rule as Bearer token or X-Sim-Webhook-Secret.',
49+
password: true,
50+
required: true,
51+
mode: 'trigger',
52+
condition: { field: 'selectedTriggerId', value: triggerId },
53+
}
54+
}
55+
56+
/**
57+
* Extra fields for ServiceNow triggers (webhook secret + optional table filter)
3958
*/
4059
export function buildServiceNowExtraFields(triggerId: string): SubBlockConfig[] {
4160
return [
61+
servicenowWebhookSecretField(triggerId),
4262
{
4363
id: 'tableName',
4464
title: 'Table Name (Optional)',

0 commit comments

Comments
 (0)