Trigger web hooks
Just before a job finishes, you can trigger any other platform by firing a web hook URL. You have the option to do this only for successful jobs or only failed jobs or both.
The URL that is fired may contain parameters related to the job that has just finished. Currently, the following parameters are supported:
JobId | The ID of the job |
Status | The status of the job (success, failure) |
Duration | The number of seconds the job took to run |
RunDate | The date and time, formatted like 2021-11-07T20:58:06.6683387+00:00 |
LinesTotal | The total number of lines in the source |
LinesProcessed | The number of lines processed |
LinesFailed | The number of lines that failed processing |
LinesSkipped | The number of lines that were skipped due to duplicate checks that are set in the profile |
LinesCreated | The number of entities that were created |
LinesUpdated | The number of entities that were updated |
FileName | The name of the file that was processed |
JobDetailUrl | The URL to the job details (can be opened by any SuperOffice user) |
CreatedCompanySelectionId | The selection ID of the selection that is created for new companies |
UpdatedCompanySelectionId | The selection ID of the selection that is created for updated companies |
CreatedPersonSelectionId | The selection ID of the selection that is created for new persons |
UpdatedPersonSelectionId | The selection ID of the selection that is created for updated persons |
CreatedSaleSelectionId | The selection ID of the selection that is created for new sales |
UpdatedSaleSelectionId | The selection ID of the selection that is created for updated sales |
CreatedProjectSelectionId | The selection ID of the selection that is created for new projects |
UpdatedProjectSelectionId | The selection ID of the selection that is created for updated projects |
CreatedAppointmentSelectionId | The selection ID of the selection that is created for new appointments |
UpdatedAppointmentSelectionId | The selection ID of the selection that is created for updated appointments |
CreatedDocumentSelectionId | The selection ID of the selection that is created for new documents |
UpdatedDocumentSelectionId | The selection ID of the selection that is created for updated documents |
CreatedQuotelineSelectionId | The selection ID of the selection that is created for new quote lines |
UpdatedQuotelineSelectionId | The selection ID of the selection that is created for updated quote lines |
CreatedRequestSelectionId | The selection ID of the selection that is created for new tickets |
UpdatedRequestSelectionId | The selection ID of the selection that is created for updated tickets |
The syntax for using the parameters uses a less-than sign and a more-than sign. Example: https://receive.webhooks.com/hook?Status=<Status>&LinesProcessed=<LinesProcessed>
Trigger a SuperOffice CRMScript
The web hook feature can also trigger a SuperOffice CRM script. This opens up further processing entities that are created or updated with DataBridge, since you can include the selection IDs of the created selections in the URL and hand them over to the CRMScript.
A CRMScript can be triggered from a URL if you include the proper parameters.
https://onlineX.superoffice.com/Cust[YOUR_CUSTID]/CS/scripts/customer.fcgi?_sf=0
&action=safeParse
&noContentType=true
&includeId=[YOUR_INCLUDE_NAME]
&key=[YOUR_KEY]
&JobId=<JobId>
&Status=<Status>
Replace X with your online environment.
Replace the values between brackets and that start with YOUR with the proper values from your SuperOffice tenant and the CRMScript you would like to trigger.
An example of a CRMScript is provided for your convenience. This script creates a task that shows some details about the job.
More information on CRMScripts can be found here.
Example:
%EJSCRIPT_START%
<%
#setLanguageLevel 3;
String JobId = getCgiVariable("JobId");
String Status = getCgiVariable("Status");
String Duration = getCgiVariable("Duration");
String RunDate = getCgiVariable("RunDate");
String LinesTotal = getCgiVariable("LinesTotal");
String LinesProcessed = getCgiVariable("LinesProcessed");
String LinesFailed = getCgiVariable("LinesFailed");
String LinesSkipped = getCgiVariable("LinesSkipped");
String LinesCreated = getCgiVariable("LinesCreated");
String LinesUpdated = getCgiVariable("LinesUpdated");
String FileName = getCgiVariable("FileName");
String JobDetailUrl = getCgiVariable("JobDetailUrl");
String CreatedCompanySelectionId = getCgiVariable("CreatedCompanySelectionId");
String UpdatedCompanySelectionId = getCgiVariable("UpdatedCompanySelectionId");
String CreatedPersonSelectionId = getCgiVariable("CreatedPersonSelectionId");
String UpdatedPersonSelectionId = getCgiVariable("UpdatedPersonSelectionId");
String CreatedSaleSelectionId = getCgiVariable("CreatedSaleSelectionId");
String UpdatedSaleSelectionId = getCgiVariable("UpdatedSaleSelectionId");
String CreatedProjectSelectionId = getCgiVariable("CreatedProjectSelectionId");
String UpdatedProjectSelectionId = getCgiVariable("UpdatedProjectSelectionId");
String CreatedAppointmentSelectionId = getCgiVariable("CreatedAppointmentSelectionId");
String UpdatedAppointmentSelectionId = getCgiVariable("UpdatedAppointmentSelectionId");
String CreatedDocumentSelectionId = getCgiVariable("CreatedDocumentSelectionId");
String UpdatedDocumentSelectionId = getCgiVariable("UpdatedDocumentSelectionId");
String CreatedQuotelineSelectionId = getCgiVariable("CreatedQuotelineSelectionId");
String UpdatedQuotelineSelectionId = getCgiVariable("UpdatedQuotelineSelectionId");
String CreatedRequestSelectionId = getCgiVariable("CreatedRequestSelectionId");
String UpdatedRequestSelectionId = getCgiVariable("UpdatedRequestSelectionId");
Integer owner = 1; // associate.associate_id
NSContact ownCompany;
ownCompany.SetContactId(2); // contact.contact_id
DateTime jobruntime;
NSAppointmentAgent appointmentAgent;
NSAppointmentEntity newTask = appointmentAgent.CreateDefaultAppointmentEntityByTypeAndAssociate(6, owner);
newTask.SetDescription("DataBridge job #" + JobId + " in " + Duration + " seconds.\nStatus: " + Status + "\nTotal lines processed: " + LinesTotal);
newTask.SetContact(ownCompany);
newTask.SetAssignmentStatus(11);
newTask.SetEndDate(jobruntime);
newTask.SetStartDate(jobruntime);
newTask = appointmentAgent.SaveAppointmentEntity(newTask);
%>
%EJSCRIPT_END%