Fel
Fel

Reputation: 4818

Import Javascript file into Camunda embedded forms

I've been asked to maintain some Camunda embedded forms (here's the documentation) to allow the user to upload files and to delete any of the existing ones. I've almost finished it in one of the forms and I have to apply the same changes to eleven more. I'd like to create an script file with the shared Javascript code to import it instead of embedding it again on all the forms but I can't find anything in the docs or elsewhere.

I tried creating the Javascript file in the following places:

In all cases, I can't reach the scripts file from the forms, neither from the URL of the browser. I'm completely new to Camunda so I'm a little lost on this...

Any suggestions? Thanks in advance,

Upvotes: 3

Views: 1068

Answers (2)

marketmi
marketmi

Reputation: 28

I located my custom Javascript-files within my project as follows:

src/main/webapp/scripts/test.js

In my embedded form I then import my script:

<form>
    //Your form elements
    <script src="../../../../name-of-war-folder/scripts/test.js"></script>
</form>

Then I am able to call my custom functions.

I think this is because the embedded forms are included from somewhere within the tasklist folder of the camunda application apache-tomcat\webapps\camunda\app\tasklist

An alternative would be to put the custom Javascript-files into the apache-tomcat\webapps\camunda\app\tasklist\scripts folder and import it with:

<script src="../scripts/test.js"></script>

Unfortunately I have not found an easier way yet to include the scripts, but at least this works for now.

Edit: I found out an easier way to include the scripts which are located under:

src/main/webapp/scripts/test.js

Simply using the tag:

<script src="/name-of-war-folder/scripts/test.js"></script>

Upvotes: 1

Fel
Fel

Reputation: 4818

It seems there's no way to load javascript files from the embedded forms, so I ended up copying and pasting the needed code to all of them.

Cheers,

Edit: @marketmi's answer works perfectly.

Upvotes: 0

Related Questions