Solution developers who use the Script Adapter widget or the Script action would like to be able to debug their scripts.
Because the scripts are embedded inside the HTML template corresponding to the page and evaluated at runtime, browser specific developer tools such as Firebug will not display the script as a normal js file. So you can’t add break points to the scripts. Usually, you have to add console.log statements between the lines of scripts for debugging purposes. Also, if you need to update the scripts, you have to open the solution in the Case Builder, update the scripts inside the page designer, and redeploy the solution.
As a solution developer, you would like to do the following
1. Debug the scripts easily.
2. Update the scripts in runtime without it being necessary to go back to Case Builder and redeploy the solution.
3. Share the scriptlets between Script Adapter instances.
In this article, we will demonstrate a simple approach of consolidating the scripts into an IBM Navigator Plugin. And the Script Adapter can then call them. A sample is attached for your reference.
Scenario: In the cases page customize the case search payload by adding an additional search criteria of a Boolean attribute must equal true.
Firstly, you will need to create an IBM Content Navigator Plugin which has the scripts consolidated into a single js file. For each piece of script, it is recommended to create a function and expose it via a global object (For e.g. icmscripts below). The enclosing function has four parameters, the first one is the event payload, the second and the third one are the solution and role context, the last one is the Script Adapter page widget instance for the script to take control of the publishing/broadcasting events itself.
Secondly, you need to register Plugin to the IBM Content Navigator. In your development environment, you should register it with the class file mode. With the class file mode, it makes easy for you to update the script file when do debugging. After build the plugin jar file, in the development environment, you should decompress the jar file to a temporary folder, and register the folder as plugin.
And finally, you will need to edit the Cases page.
Open the solution in Case Builder.
Edit the Cases page and edit the Case Search page widget settings.
Disable the broadcasting of ‘icm.SearchCases’ event.
Add a Script Adapter widget to this page
Wire the Script Adapter's ‘icm.ReceiveEvent’ to the Case search widget's ‘icm.SearchCases’ event
Wire the Script Adapter's ‘icm.SendEventPayload’ to the Case List widget's ‘icm.SearchCases’ event.
In the Script Adapter configuration, you must input the following line of code to call the function enclosing the script exposed from the IBM Navigator Plugin with the necessary parameters passed in.
In your development environment, when debugging the script, you can find the Script js file in firebug or other browser development tools. You can then add break points and do your debugging. If you need to update the scripts, you just need to update the script js file in the folder of the uncompressed IBM Content Navigator Plugin jar. Then clear your browser cache and reload your page.
- Script Plugin Project
Please unzip it, and import to eclipse, run ant build for generating the plugin.jar
- Test Script Solution
Please import it to your IBM Case Manager using the IBM Case Manager Admin Client.
(Tested with IBM Case Manager 184.108.40.206)