Reuse of functionality (ie javascripts)

Hi
I’m new to OL Connect and am trying to work my ways around the basics at the moment. My company is moving from Pres to OL Connect and in Pres we have PDI files that contain general functions that are used in many of our scripts or letter templates by calling on the PDI from the main script to use the functionality. This way we don’t have to write the same code in every script, and if the general functionality changes, we can change it in one place instead of in every script using the function. The functionality could be creating pdf filenames in a specific manner or adding rows of information regarding each posts in a log file.

I have tried to figure out if there is a similar functionality in OL Connect like a library of javascripts or functions that can be called from the data models or templates but have come up short so far. Perhaps this is a unusual need or requirement, but reusable functionality seems common to me.

Have anyone here you came across the same problem and have you come up with a solution or a workaround?

Hi @Carina,

On the template designer side you can refer to a library of external scripts using remote control scripts. This feature was introduced in Connect 2024.2. See the “Using a remote Control Script” section at Control Scripts.

Thank you for swift reply, but as I understand the control scripts can only be used to alter the design of the document.

I’m looking for a way to call scripts that for example set the name of the resulting pdf or add rows of information regarding each posts to a log file.

Maybe someone else will chime in, unfortunately I only know about the template designer side of scripting.

Connect Designer Template

In this, scripts will be used to modify/create the template (layout)
Managing scripts/Import Export scripts

Connect Designer Datamapper

In this, you can run script to alter the data, fetch new data fom databases, output data to external files.
External Javascript Librairies

Connect Workflow

In this you can run scripts in various language to perform basically anything the script language allows you too. Be warned that Workflow is a synchronous application so asynchonous call might not always work as intended.

Including JavaScript files in Workflow

That should give you a head start. Hope that helps.

1 Like

Thanks Sander and jchamel. I’ll try your suggestions.

In a client setup I implemented in a hacky way external scripts.

You can refer to this thread [Solved] How to implement a Designer global external function?

The gist is I have a repository folder, the path is set as a datamapper and template runtime parameters with a sane default. Then I load and execute the scripts. Mind that the loading and execution in the datamapper and template is achieved differently.

At runtime I can specify a different path for testing. The path prefix is dynamic, inside the repository folder instead folders and script names become hard coded.

With this setup I achieved a dozen of scripts reused in 30 datamappers and 30 templates which all share business logic backbone.