External javascript file

Hello,

is there any opportunity to import an external JavaScript file in a tasklist embedded form?
In the examples we have an embedded javascript file which looks like this:

<script cam-script type="text/form-script">
//your javascript code here
</script>

Can we import the script file like this?:

<script cam-script type="text/form-script" src="script.js"></script>

We tried this but it doesn’t work.

Thanks!
Best regards
Anne

Hi Anne,

could you describe what you are trying to achieve? What is in the external Javascript file? Maybe Custom Scripts are a better way to import your file.

Best regards
Sebastian

Hi Sebastian,

I want to made some change in the embedded form, e.g. add HTML Elements, …
My javascript is a part of one task and not for all tasks on my server (I think that was described in the link that you sent).

For example:
You have this HTML Code in your process (for your start task):

<form role="form" class="form-horizontal">
  <script cam-script type="text/form-script">

    camForm.on('form-loaded', function () {
      // tell the form SDK to fetch the json variable name 'customer'
      camFom.variableManager.fetchVariable('customer');
    });

  </script>
  <div class="control-group">
    <label class="control-label" for="firstName">First Name</label>
    <div class="controls">
      <input id="firstName" class="form-control"
             type="text" ng-model="customer.firstName" required />
    </div>
  </div>
</form>

I want to write the part in the script-tag in an external javascript file and want to import it in the form part. So that no javascript part will be in the HTML file.
E.g.:

<form role="form" class="form-horizontal">
  <script cam-script type="text/form-script" src="myScript.js"></script>
  <div class="control-group">
    <label class="control-label" for="firstName">First Name</label>
    <div class="controls">
      <input id="firstName" class="form-control"
             type="text" ng-model="customer.firstName" required />
    </div>
  </div>
</form>

I hope that helps to describe my problem :).

Thank you!

1 Like

Have someone an idea?
Thank you.

Not sure about the performance on this, but you could pull code for the following example we did for loading data from a deployed file:

In the above you loaded data from a deployment resource (such as a json file) to populate a drop down menu/list in a start form.

You could use the same idea to pull in your script (i think). Would need some testing.

Thanks StephenOTT for your reply. But this doesn’t works for me.
I found another forum post with that request and here no one found a solution:

You can directly import your script ?

I tried like this and it worked example :

I put my external script myScript.js inside this folder

/META-INF/resources/js/myScript.js

i can access it http://localhost:8080/js/myScript.js

inside Html you have to mention

<head> <script src="/js/myScript.js"></script> </head>

If this doesn’t work and more of cam-script related work is there then i don’t think so we can do it , we have to write inline