Error in Deluge script, but all should be OK
I get an error when using the following deluge script (sensitive info changed with ***).
This script should parse a projectnumber out of the subject or body text and put it in a custom field of the ticket.
The error:
Validation failed for the condition : Syntax error. Expecting ']' or invokeurl parameter values. Found ','.. LineNumber : 10
The code:
- // Validate ticketId (numeric)
- if (ticketId == null) {
- info "Error: ticketId is null";
- return;
- }
- // Fetch ticket details
- try {
- ticketDetails = invokeurl [
- url: "https://***.nl/api/v1/tickets/" + ticketId,
- type: GET,
- connection: "myapi"
- ];
- } catch (e) {
- info "Fetch ticketDetails Error: " + e;
- return;
- }
- // Fetch latest thread
- try {
- threadDetails = invokeurl [
- url: "https://***.nl/api/v1/tickets/" + ticketId + "/latestThread?include=plainText",
- type: GET,
- connection: "myapi"
- ];
- } catch (e) {
- info "Fetch threadDetails Error: " + e;
- return;
- }
- // Extract content and initialize
- ticketSubject = ticketDetails.get("subject");
- ticketBody = threadDetails.get("plainText");
- projectNumber = "";
- info "Subject/Body: " + ticketSubject + " | " + ticketBody;
- // Search in subject for B + 5 digits
- if (ticketSubject != null && ticketSubject != "" && ticketSubject.length() >= 6) {
- len = ticketSubject.length();
- maxStart = len - 6;
- for idx = 0; idx <= maxStart; idx = idx + 1 {
- candidate = ticketSubject.substring(idx, idx + 6);
- if (candidate.substring(0,1).toUpperCase() == "B" && candidate.substring(1,6).matches("\\d{5}")) {
- projectNumber = candidate;
- break;
- }
- }
- }
- // If not found in subject, search in body
- if (projectNumber == "" && ticketBody != null && ticketBody != "" && ticketBody.length() >= 6) {
- len = ticketBody.length();
- maxStart = len - 6;
- for idx = 0; idx <= maxStart; idx = idx + 1 {
- candidate = ticketBody.substring(idx, idx + 6);
- if (candidate.substring(0,1).toUpperCase() == "B" && candidate.substring(1,6).matches("\\d{5}")) {
- projectNumber = candidate;
- break;
- }
- }
- }
- info "projectNumber: " + projectNumber;
- // Update custom field if found
- if (projectNumber != "") {
- customFieldsMap = Map();
- customFieldsMap.put("cf_b_nummer", projectNumber);
- updateData = Map();
- updateData.put("customFields", customFieldsMap);
- try {
- invokeurl [
- url: "https://***.nl/api/v1/tickets/" + ticketId,
- type: PATCH,
- headers: {"Content-Type":"application/json"},
- parameters: updateData,
- connection: "myapi"
- ];
- info "Project number updated successfully";
- } catch (e) {
- info "Update Error: " + e;
- }
- }
Somebody knows where to look? I really don't understand whats wrong with the script. The invokeurl is correctly formatted.