Deluge Statement not updating the ticket comments

Deluge Statement not updating the ticket comments

I am trying to concatenate fields values in the zoho desk ticket into a single summary comment in the ticket so that we can copy and paste this into a partner system to escalate cases. The script saves and says it runs successfully when you give it a ticket to run against but no comment is being put in the ticket.  See statement below:

// Fetch the ticket record using the passed workflow argument
ticketDetails = zoho.desk.getRecordById(812118909,"tickets",ticketId);
// 2. Extract standard and custom fields (Handle null values carefully)
subject = ifnull(ticketDetails.get("subject"),"No Subject");
description = ifnull(ticketDetails.get("description"),"No Description");
// For custom fields, use the custom field API name structure
BusinessImpact = ifnull(ticketDetails.get("cf").get("cf_business_impact"),"");
StepsReproduce = ifnull(ticketDetails.get("cf").get("cf_steps_to_reproduce"),"");
ProductorModule = ifnull(ticketDetails.get("cf").get("cf_product_module"),"");
Version = ifnull(ticketDetails.get("cf").get("cf_version"),"");
FirstOccurence = ifnull(ticketDetails.get("cf").get("cf_date_of_1st_occurrence_other_related_case_numbers"),"");
AnyRecentChanges = ifnull(ticketDetails.get("cf").get("cf_any_recent_changes"),"");
PermissionsValidated = ifnull(ticketDetails.get("cf").get("cf_permissions_validated"),"");
ConfigurationReviewed = ifnull(ticketDetails.get("cf").get("cf_configuration_reviewed"),"");
LogsReviewed = ifnull(ticketDetails.get("cf").get("cf_logs_reviewed"),"");
DocumentationSearched = ifnull(ticketDetails.get("cf").get("cf_documentation_searched"),"");
KnownIssuesReviewed = ifnull(ticketDetails.get("cf").get("cf_known_issues_reviewed"),"");
ConnectivityVerified = ifnull(ticketDetails.get("cf").get("cf_services_connectivity_verified"),"");
LogsAttached = ifnull(ticketDetails.get("cf").get("cf_logs_attached"),"");
ScreenshotsAttached = ifnull(ticketDetails.get("cf").get("cf_screenshots_attached"),"");
// 3. Concatenate fields into a single structured note block
combinedNote = "--- CONSOLIDATED TICKET DATA ---" + "\n" + "Subject: " + subject + "\n" + "Description: " + description + "\n" + "Business Impact: " + BusinessImpact + "\n" + "Steps to Reproduce: " + StepsReproduce + "\n" + "Product or Module: " + ProductorModule + "\n" + "Version: " + Version + "\n" + "First Occurence: " + FirstOccurence + "\n" + "Any Recent Changes: " + AnyRecentChanges + "\n" + "Permissions Validated: " + PermissionsValidated + "\n" + "Configuration Reviewed: " + ConfigurationReviewed + "\n" + "Logs Reviewed: " + LogsReviewed + "\n" + "Documentation Searched: " + DocumentationSearched + "\n" + "Known Issues Reviewed: " + KnownIssuesReviewed + "\n" + "Connectivity Verified: " + ConnectivityVerified + "\n" + "Logs Attached: " + LogsAttached + "\n" + "Screenshots Attached: " + ScreenshotsAttached;
// 4. Build the map payload for the comment
// Set "isPublic" to "false" to keep it as an internal agent note, or "true" for a public comment
commentPayload = Map();
commentPayload.put("content",combinedNote);
commentPayload.put("isPublic","false");
// 5. Use invokeurl to post the note to the ticket via API
response = invokeurl
[
url :"https://zoho.com" + 812118909 + "/tickets/" + ticketId + "/comments"
type :POST
parameters:commentPayload.toString()