Skip to main content

Scripting and REST API improvements

The following improvements to the ConSol CM API and REST API have been made.

Contact update action extended (#628053)

The scope of contact update actions has been extended. They are now executed also when deactivating or activating a contact. This allows reacting on an activation and deactivation in the update script.

The class UnitChanges has been extended with the methods getActivationChangeInfo() and setActivationChangeInfo(). You can check if a contact was activated or deactivated by using the getActivationChangeInfo() method on the changes object.

changes.getActivationChangeInfo()

This returns a modification with the current and previous values, with "true" meaning that the contact is active and "false" that the contact is deactivated.

Improved handling of embedded images in emails (#656443)

Embedded images are now handled correctly in all kinds of outgoing emails, so that they are displayed properly in email clients. This includes complex scenarios, as for example outgoing emails which are created by script based on templates which include rich text fields, where the Web Client user can paste images.

note

The workaround which removes the filename tags in the source code of the email are not required anymore.

Position attribute removed from REST response (#656642)

The position attribute has been removed from the REST response when retrieving an activity form using the activityformfieldssets endpoint. Custom REST clients which it must be adapted to support the new fieldPosition attribute, which was introduced first in ConSol CM version 6.16.0.0.

Example output with the new attribute:

"fieldPosition": {
"row": 1,
"column": 2,
"rowspan": 1,
"colspan": 1
}

New NIMH script for handling erroneous emails (#656841)

ConSol CM now provides more flexibility when handling erroneous emails which cannot be processed. The desired behavior can now be configured in the script NimhErroneousMessageHandling.groovy. This script is executed automatically if the processing of the email fails.

The behavior depends on the return value of the script:

  • true: A backup of the failed email is saved to the Failed incoming emails page of the Web Admin Suite.
  • false: No (further) processing takes place.

You can implement other actions prior to the return statement.

By default, i.e. if you do not modify the script at all, a backup of the failed email is saved to the Failed incoming emails page of the Web Admin Suite, where the administrator can download or retry the email. This is the behavior from previous versions of ConSol CM.

Alternatively, it can be configured to create a case where the failed email is attached, or to attach the failed email to an existing case. The script NimhErroneousMessageHandling.groovy contains example code to help with the configuration. If you want to enable an alternative behavior, you need to comment in the respective parts of the script and adapt the example code to your configuration.

You can also implement any other behavior in the script, or choose to ignore unparsable emails completely.

note

The script NimhErroneousMessageHandling.groovy is added automatically when setting up a new ConSol CM system or updating an existing system to version 6.17.0.0.

Easier styling of PDF documents (#658526)

The ConSol CM API includes the method generatePDFDocumentFromXHTML in ContentFileTemplateService to create PDF documents from XHTML content.

By default, when using this method, the following styles are now applied to the PDF document to avoid that images overflow the page borders:

@page {
size: A4;
margin: 1in;
}

img {
fs-fit-images-to-width: 100%;
page-break-inside: avoid !important;
}

You can pass additional CSS styles using the @page annotation in the XHTML content passed to generatePDFDocumentFromXHTML(String pFileName, String pXHTML). These styles are added to the default ones.

If you want to override the default styles, you can use the new method signature generatePDFDocumentFromXHTM(String pFileName, String pXHTML, InputStream pCssInputStream) to pass styles via the input stream parameters.

The following example adds a green background color and allows images to span only 50% of the document width.

byte[] blob = "@page {size: A4; margin: 1in; background-color: green;} img{-fs-fit-images-to-width: 50%; page-break-inside: avoid !important;}".getBytes();
ByteArrayInputStream bais = new ByteArrayInputStream(blob);
ContentFile content = contentFileTemplateService.generatePDFDocumentFromXHTML(fileName, html, bais);

Loop detection mechanism disabled (#659358)

The mechanism which automatically detects workflow loops is now disabled by default. Instead of throwing an exception, which could block the execution of valid business logic, a warning is written to the log files if a loop is detected.

The previous behavior of the loop detection, i.e. exception to block execution in case of a loop, can be enabled again by adding the following code to a workflow script:

ExecutionTracker.enableLoopDetectionFuse()

If the loop detection is disabled explicitly in a script by using ExecutionTracker.disableLoopDetection(), no warnings are written to the log files and there are no exceptions. This means that the behavior of this method has not been changed.

You can use ExecutionTracker.enableLoopDetection() to explicitly configure the new default behavior in a script.

Changed behavior when using an empty value as a search criterion (#659662)

When passing a null parameter or an empty string for a data field to a search method in a script, an exception of the type IllegalArgumentException is now thrown and the search is not executed. Previously, null parameters and empty strings for data fields were treated as wildcards so that instead of limiting the search, all cases, contacts or resources were found, which could lead to performance problems due to loading a high number of objects.

warning

You need to adapt your scripts to ensure that all data field criteria which are passed to CustomFieldCriteriaBuilder, TicketCriteria, UnitCriteria and ResourceCriteria have values. Otherwise, the search will not work anymore.

info

The ETL plugins Contact ID lookup and Resource ID lookup are not affected by this change. If an empty value is passed to the plugin, it is internally replaced by an asterisk to avoid this new exception.

Methods for handling participants (#660355)

The ConSol CM API has been extended by methods which allow to handle participants of cases without having to provide the user function.

The following methods have been added to the class TicketUserService:

  • getTicketUsers (Ticket pTicket)
  • removeTicketUsers (Ticket pTicket)

The following methods have been added to the class WorkflowContextService:

  • getTicketUsers()
  • getTicketUsers (Ticket pTicket)