Create ServiceNow Business Rules and REST Messages to automatically send work order data to Field Nation.
Business Rule: Monitors records and evaluates conditions REST Message: Sends sys_id to Field Nation Field Nation: Fetches full record data and creates work order
REST Messages define the HTTP request sent to Field Nation.
ServiceNow → System Web Services → Outbound → REST Message
Click New
Name: Field Nation Integration
Endpoint: Paste Field Nation trigger URL
https://api.fieldnation.com/integrations/trigger/{CLIENT_TOKEN}Description: Sends incident data to Field Nation for work order creation
Authentication: None (authentication handled by client token in URL)
Click Submit
Find your "Field Nation Integration" REST Message → Open it
Scroll to HTTP Methods related list → Click New
Name: SendToFieldNation
HTTP Method: POST
Endpoint: Use parent endpoint (already set)
Content: application/json
HTTP Request Body:
{
"sys_id": "${sys_id}",
"table": "${table}",
"timestamp": "${timestamp}"
}Add header if needed:
Name: Content-Type
Value: application/jsonClick Submit
Click on "SendToFieldNation" method
In Variable Substitutions section:
sys_id: test_12345
table: incident
timestamp: 2025-01-15 10:30:00Button at bottom of form
Success: 200 OK response Failure: Check error message, verify trigger URL
Business Rules provide the automation logic to trigger REST Messages.
ServiceNow → System Definition → Business Rules
Click New
Name: Field Nation - Create Work Order
Table: Select your table (e.g., incident)
Active: ✅ Checked
Advanced: ✅ Checked (required for script)
When:
When to run:
Condition:
Option 1: Checkbox Trigger
Custom Field "Send to Field Nation" = trueOption 2: State-Based Trigger
State CHANGES TO On-Site RequiredOption 3: Assignment-Based Trigger
Assignment Group CHANGES
AND
Assignment Group.Name CONTAINS FieldOption 4: Combined Conditions
State = On-Site Required
AND
Priority IN (1-Critical, 2-High)
AND
Assignment Group.Name = Field ServicesAdvanced tab → Script field:
(function executeRule(current, previous /*null when async*/) {
try {
// Get REST Message
var r = new sn_ws.RESTMessageV2('Field Nation Integration', 'SendToFieldNation');
// Set parameters
r.setStringParameterNoEscape('sys_id', current.sys_id.toString());
r.setStringParameterNoEscape('table', current.getTableName());
r.setStringParameterNoEscape('timestamp', new GlideDateTime().toString());
// Execute REST call
var response = r.execute();
var httpStatus = response.getStatusCode();
// Log result
if (httpStatus == 200 || httpStatus == 201) {
gs.info('Field Nation: Successfully sent ' + current.getTableName() + ' ' + current.sys_id + ' to Field Nation');
// Optional: Update field to indicate sync
// current.u_fn_sync_status = 'sent';
// current.update();
} else {
gs.error('Field Nation: Failed to send to Field Nation. Status: ' + httpStatus + ', Body: ' + response.getBody());
}
} catch (ex) {
gs.error('Field Nation: Exception sending to Field Nation: ' + ex.message);
}
})(current, previous);Prevent Duplicate Sends:
Add condition to check if already sent:
(function executeRule(current, previous) {
// Skip if already sent
if (current.u_fn_sync_status == 'sent') {
gs.info('Field Nation: Record already sent, skipping');
return;
}
try {
var r = new sn_ws.RESTMessageV2('Field Nation Integration', 'SendToFieldNation');
// ... rest of script
// Mark as sent
current.u_fn_sync_status = 'sent';
current.setWorkflow(false); // Prevent recursive triggers
current.update();
} catch (ex) {
gs.error('Field Nation: Exception: ' + ex.message);
}
})(current, previous);Click Submit
Check System Logs → System Log → All:
Send different fields based on priority:
(function executeRule(current, previous) {
var r = new sn_ws.RESTMessageV2('Field Nation Integration', 'SendToFieldNation');
r.setStringParameterNoEscape('sys_id', current.sys_id.toString());
r.setStringParameterNoEscape('table', current.getTableName());
r.setStringParameterNoEscape('priority', current.priority.toString());
// Add additional data for high priority
if (current.priority <= 2) {
r.setStringParameterNoEscape('urgent', 'true');
r.setStringParameterNoEscape('escalation_contact', current.caller_id.email.toString());
}
var response = r.execute();
// ... handle response
})(current, previous);Business Rule 1: High Priority Incidents
Priority = 1-Critical
State = On-Site Required
→ Immediate dispatchBusiness Rule 2: Standard Incidents
State = On-Site Required
Priority != 1-Critical
→ Normal dispatchBusiness Rule 3: Emergency After-Hours
Priority = 1-Critical
Created During: After hours (use script)
→ Emergency dispatch with special handlingTo update ServiceNow when Field Nation changes:
Example Scripted REST API:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var payload = request.body.data;
var fn_wo_id = payload.workorder_id;
var fn_status = payload.status;
var sys_id = payload.correlation_id; // ServiceNow sys_id
var gr = new GlideRecord('incident');
if (gr.get(sys_id)) {
// Map FN status to ServiceNow state
if (fn_status == 'assigned') {
gr.state = 2; // In Progress
} else if (fn_status == 'work_done') {
gr.state = 4; // Resolved
}
// Add work note
gr.work_notes = 'Field Nation work order ' + fn_wo_id + ' status: ' + fn_status;
gr.update();
response.setStatus(200);
response.setBody({success: true});
} else {
response.setStatus(404);
response.setBody({error: 'Record not found'});
}
})(request, response);Switch Field Nation from Sandbox to Production:
Daily:
Weekly:
Monthly:
Last updated on