You can call to the third-party websites to use data your need in a database, for example, currency exchange rates, companies’ logos, cities and addresses, etc. In this case the Call URL workflow action can be added to the trigger or custom button.
The Call URL workflow action performs HTTP GET requests (support for POST and more advanced options is planned for the next stage) and understands responses in plain text, XML and JSON formats. To create this type of action:
Select a corresponding option on the.
Beside the general purpose (Name and Description fields) the action has the Url field. Also, you should use <% %> code blocks to provide parameters.
Upon request the service can either return a failure code [this will be added in a log and further processing will be stopped] or report OK and provide an error message in the response. To help dealing with such situation there is the Error Formula field - you can extract error message from the response or return NULL if response is OK.
To deal with the data returned by the server there is a new Response() function that takes three forms:
Response() with no arguments returns the "raw" content of the server response - you can use it if the server provides the result in a plain text format.
Response("text") - extracts named data from the response in the XML or JSON format. In case of XML the text should be a valid XPath expression, in case of JSON it's a string in form of "property.property[index].property". The function returns the value as text.
Response("text", Type) - performs as previous one but also tries to convert the result to TeamDesk-specific type.
You can use calls to Response() in both error formulas and assignments.
Once the action is created, the Assignment can be added to it:
Use the following form to create the assignment for extracting the value from the third-party website and updating this value in the column:
In the From field enter the formula extracting the value from the third-party website. This value will be later on inserted into a predefined record field.
In the To list select the field (column) to which the formula calculated value should be inserted.
Call URL’s On Error option
The quick recap on Call URL logic:
Step1: TeamDesk calls third-party server.
If there is a network error, roll back all changes and display error message.
Step 2: TeamDesk evaluates response status.
If status indicates error, roll back all changes and display generic message.
Step 3: TeamDesk evaluates Error Message formula, if not empty.
If formula evaluates to some text, roll back all changes and display text as error message.
Step 4: Execute assignments and subsequent triggers and actions normally.
The On Error option controls the behavior at step 2.
If set to Stop Execution we use old logic – this option is a default.
If you need greater flexibility, set On Error to Continue Execution. Step 2 will be skipped. Error Message formula, if set, handles both successful and error responses. The formula has a chance to evaluate response status using the ResponseStatus() function. Then it can extract a specific error message from server’s response and abort execution if needed, or return NULL to suppress error and continue execution.
If execution is not aborted, you can use assignments to flag whether the record was successfully processed or not, for example:
If(ResponseStatus() = 200, “OK”, “FAILED!”) // to Status
Next: Mobile Device Record Create