Video Screencast Help

Is it possible to use javascript or similar in SendMail or MergeHTML componets?

Created: 09 Jul 2013 | 4 comments


I am developing a workflow that processes some data and at the end it shall send a mail to the user. The content of the mail will be dynamic based on the data that was processed during the execution. I have tried (and failed =) ) to use javascript in both SendMail/MergeHTML but it doesnt seem to trigger the actual script..

Is it possible to use javascript or similar in the SendMail component or in the MergeHTML components? Or are there any other components that are specifically dedicated to this?  



Operating Systems:

Comments 4 CommentsJump to latest comment

PeeGee's picture

Hi Christoffer,

there are many different ways how you can run JavaScript.
In general I am wondering if it is even required, as all the data you are collecting with your workflow should be in your variables, thus easily useable in the send e-mail component.

Anyway, if you require to run JavaScript, have a look at the following possibilities/places:

- In the form builder double-click on empty space to get into the properties of the form. Click on the "Behaviour" tab and sroll to the bottom. There is a script section.

- Additionally you can use "custom events" in the form builder itself or on any component that you can use in the form builder. Just double-click on the component (for example a button), add a custom event like "onactivate" or "onclick" and put your javascript into the "Event Handler" field.

- You can also drag and drop the "IncludeHTML" component into the form and add your javascript into it

ecerjon's picture

Hi PeeGee,

Thanks for your suggestions! To answer, yes we are using those features when we are in a Forms project.. the thing right now though is that I am not using a forms project, its a workflow project without any attached "web frontend".

Perhaps I should elaborate a bit more on my scenario to make it a bit more clear.

In my workflow I have a number of operations that returns arrays/collections, and later in my mail I want to check the number of items a collection contains and take some action based on that or check a value in the array to see if it matches X.

I could do this by adding a number of "foreach in collection" and "equals" components and then merge all the results togheter in a String variable. I have that solution today and it works but its quite hard to follow even when naming the different components programatically for what they are doing. 

So hence my question if it is possible to use some component and write a few lines of javascript that does the same.

Thank you for your time!

*edit: Added "not" 

PeeGee's picture

Hi again,

by design JavaScript runs in the users browser, thus you can only use JavaScript, if you also have a UI, thus those parts are only available inside the form designer.

Anyway if you are looking for a programmatic approach and do not like to have too many components in Workflow, you could have a look at the "Run Script" component and at the integration components, which will allow you to run fun stuff like C#.

Usually I am using the embedded model, embedded rule model or entirely own models inside projects to get a cleaner look.