Make Skedulo API Notification requests using Salesforce

Dispatch jobs and notify resources from Salesforce using the Skedulo API.

Global Notification inputs are used for all API requests that dispatch job notifications to resources and are defined in the following way:

global Notification(<jobId>, <resourceId>)

Any Skedulo API can be called from Salesforce using the generic Skedulo API wrapper.

The following notification functions have been given specific methods to make it easier to call them from Salesforce:

  • Notify
  • Notify Cancel
  • Dispatch
  • Distance Matrix
  • OneOff API
  • Skedulo SMS
  • Geolocation

Dispatch a job and notify the resource from Salesforce using the Skedulo API

  1. Log in to your Skedulo account in Salesforce.
  2. Create a new job, or find the jobId of a job that you want to dispatch or send a notification to the resource.
  3. Open the Developer Console. a. Click the Settings cog in the upper-right corner. b. Select Developer Console.
  4. Select Debug -> Open Execute Anonymous Window, or press Ctrl + E.
  5. Enter the following code using the correct jobId to dispatch the job and notify the resource.
sked.ApiResult.NotificationResult result = sked.SkeduloAPI.dispatch('<jobId>', '<resourceId>');
System.debug(result);
  1. Click Execute.
  2. Select the Debug Only filter in the Execution Log and open the USER_DEBUG event to view the log and confirm the job has been dispatched.

If the job has been dispatched correctly, the log results should display the resourceId and method of notification, with no errors, and a 200 status code:

14:31:39:541 USER_DEBUG [2]|DEBUG|NotificationResult:[Generic.message=null, Generic.response={"result":{"jobId":"a0G2v00002hB0wuEAC","results":[{"resourceId":"a0X2v00000MKTovEAH","protocol":"sms","error":null}]}}, Generic.status=OK, Generic.statusCode=200, Generic.success=true, result=JobNotification:[jobId=a0G2v00002hB0wuEAC, results=(ResourceNotification:[error=null, protocol=sms, resourceId=a0X2v00000MKTovEAH])]]

Logs that show no results (results=()) or an error message have not dispatched correctly.

The following is an example log response where the Skedulo API token is invalid:

14:27:00:652 USER_DEBUG [2]|DEBUG|NotificationResult:[Generic.message=API Token gAzH8QSNY2R3SQCnle5DBlrV55YaHYe1 was revoked, Generic.response={"errorType":"api_token_authentication_error","message":"API Token gAzH8QSNY2R3SQCnle5DBlrV55YaHYe1 was revoked"}, Generic.status=Unauthorized, Generic.statusCode=401, Generic.success=false, result=null]

Example: Send a oneoff SMS to a resource from Salesforce using the Skedulo API

You can use the OneOff API to send a one off text message or notification to a resource from Salesforce using the Skedulo API.

Enter the following code in the Developer Console window, then click Execute:

sked.ApiResult.OneOff result = sked.SkeduloAPI.oneoff('<resourceId', '<message>' , '<protocol>');

The execution log confirms the resource user information and the method used to send the message.