How can I use the imported JavaScript method?

Hi,

I’ve known that a Run Script in a workflow cannot use the trim() method of JavaScript, so I’ve created a small function. I would like to use this function in many workflows. Therefore, I’ve created a functions.js file and imported it into the Run Script as a Script file. However, I do not know how to use the function in the Run Script. Could someone tell me how to do it?

image

You can use the trim() function in Javascript in Workflow. Just make sure that the language you select in the Run Script plugin is Enhanced JScript and not JScript

var myString = ’   bloublou   ';

myString = myString.trim();

Watch.Log(myString,1);

// bloublou

Also, note that you can use Include modules in Workflow so that your scripts can call methods and objects stored in user-defined modules:

There are a couple of articles about that feature on the Resource Center, but you can start by reading this one.

@jchamel ,

Thank you for your information. I’ve confirmed that I can use trim() by Enhanced JScript mode.

@Phil ,

I cannot see the Plug-in → Scripts on OL Connect Workflow Preferences window. Do you know why? My workflow version is 2024.1.1.6626.

You can see that item on 2024.2.x (or later)

Hi @tosuji ,

Thank you for your response. I’ll consider to version up the workflow.