Automated Geofence Creation for Salesforce Work Orders - n8n Workflow

Use this robust n8n workflow to automatically create geofence zones in Geotab whenever a new Salesforce Work Order with geo-location data is created. Integrate CRM and telematics efficiently.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

-
Field Service Managers needing automated synchronization between CRM and fleet management systems.
System Administrators managing Salesforce and telematics platforms (like Geotab).
n8n power users seeking advanced examples of API integration and custom scripting within an n8n workflow.
Organizations looking for professional n8n templates to bridge operational systems.

Overview

Managing field service operations requires seamless coordination between job management (CRM) and vehicle tracking (telematics). This powerful n8n workflow solves the manual pain point of creating geofence zones for every new work order. When a new Work Order is created in Salesforce, this n8n trigger instantly starts the automation. The workflow checks if valid latitude and longitude data exists. If the data is present, the n8n workflow calculates the geofence perimeter and uses the Geotab API to create a new zone, subsequently updating the original Salesforce record with the Geotab Zone ID. If geo-location data is missing, the n8n automation sends an immediate notification via Microsoft Outlook, ensuring operational data quality. This streamlined process demonstrates the power of a customized n8n implementation.

How it Works

This comprehensive n8n workflow begins when a new Work Order record is detected in Salesforce via an Outbound Message configured to send a SOAP request to the Salesforce Webhook n8n trigger.


  1. Trigger & Acknowledge: The Salesforce Webhook receives the request, sends an immediate SOAP acknowledgement using the Respond to Webhook n8n node, and then pauses using the Wait n8n node to ensure Salesforce has processed the acknowledgement.

  2. Retrieve Data: The Get Work Order details n8n node pulls the complete Work Order record from Salesforce using the ID provided by the webhook payload.

  3. Data Prep & Check: The Extract required fields n8n node isolates essential data points. The If has location n8n node uses conditional logic to check for the presence of Address.latitude.

  4. Path A (Success - Location Available):

a. Data is organized for the API by the Prepare data for GeoTab n8n node.
b. The Calculate points Code n8n node runs custom JavaScript to generate 20 coordinate points defining a 200-meter circular geofence around the center latitude/longitude.
c. The workflow authenticates with Geotab using the GeoTab authentication HTTP Request n8n node.
d. The Calculate zone's active dates Code n8n node determines the start and end dates for the zone's active period.
e. The Create zone in GeoTab HTTP Request n8n node uses the gathered data (credentials, calculated points, work order details) to call the Geotab 'Add' method and create the zone.
f. The Update Salesforce with zone details n8n node updates the Salesforce Work Order record with the new Geotab Zone ID and sets a confirmation flag.
g. A detailed confirmation email is sent via the Email notification - success Outlook n8n node.

  1. Path B (Failure - Missing Location): If the location check fails, the Email notification - error Outlook n8n node sends an alert to the Operations team or Work Order owner, requesting manual data correction.

Installation Guide

To deploy this n8n workflow template, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' button or 'Import from JSON' option.

  2. Configure Salesforce Webhook:

Open the Salesforce Webhook n8n trigger node and click 'Show settings'.
Copy the generated 'Webhook URL'.
In your Salesforce Setup, create a new Outbound Message for the Work Order object and paste the n8n webhook URL. Ensure your Workflow Rule or Flow correctly triggers this outbound message upon Work Order creation and includes necessary fields (ID, WorkOrderNumber, Address fields, etc.).

  1. Set Up Credentials: Configure or select existing credentials for the following services:

Salesforce Account: Connect via OAuth2 in the Get Work Order details and Update Salesforce with zone details n8n nodes.
Microsoft Outlook Account: Connect via OAuth2 in both email notification n8n nodes.

  1. Configure Geotab API: The Geotab integration uses HTTP Request n8n nodes, requiring manual credential input within the JSON body:

In the GeoTab authentication n8n node, replace placeholders (e.g., YOURGEOTABDATABASENAME, [email protected], YOURGEOTABUSERPASSWORD) in the JSON body.
Repeat this step for the credentials object within the Create zone in GeoTab n8n node.
Ensure the Salesforce object API name (WorkOrder) and Geotab group ID (GroupCompanyId) are correctly set in the corresponding n8n nodes.

Node Details

This advanced n8n workflow utilizes several key n8n nodes to achieve system integration:

Salesforce Webhook (n8n trigger): The starting point. Configured to listen for POST requests sent by Salesforce Outbound Messages, specifically anticipating a SOAP envelope containing the Work Order ID.
Get Work Order details (Salesforce n8n node): Retrieves all necessary fields for the Work Order using the ID extracted from the webhook payload. Crucial for obtaining geo-location data and other details needed for the Geotab zone.
If has location (If n8n node): A core logic node that checks if the Address.latitude field is populated. It directs the flow to either the Geotab creation path or the error notification path.
Calculate points (Code n8n node): Executes custom JavaScript to perform a geospatial calculation. It takes the center latitude/longitude and generates 20 points defining a circular zone with a 200-meter radius, preparing the polygon data required by the Geotab API. This customization showcases flexibility within an n8n workflow.
GeoTab authentication (HTTP Request n8n node): Performs a direct API call to Geotab to obtain a session ID, which is necessary for subsequent zone creation actions. Credentials must be hardcoded into the JSON request body.
Create zone in GeoTab (HTTP Request n8n node): Calls the Geotab 'Add' method, passing the session ID, calculated geofence points, and Work Order metadata (Name, Reference, ExternalReference) to finalize the zone creation.
Update Salesforce with zone details (Salesforce n8n node): Uses the update operation to write the newly created Geotab Zone ID back to the WorkOrder object in Salesforce, maintaining data integrity.
Email notification - success / error (Microsoft Outlook n8n node): Sends targeted email notifications for both successful zone creation (including links to the Geotab zone and Salesforce record) and failure scenarios (missing geo-location data).

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by
Sobek
Sobek

IT Manager and automation architect with expertise in Salesforce, Microsoft 365, and n8n. I build robust, production-grade workflows that solve real business problems—no fluff, just practical automation. Let’s streamline your operations with smart, maintainable solutions.

Featured*