How to do javascript calculation in the form field

cancel
Showing results for 
Search instead for 
Did you mean: 
sprincess
Member II

How to do javascript calculation in the form field

Jump to solution

Hi, I'm new to Alfresco Activiti.

I've already desgin a flow on activiti-app with a simple form.

In the form, there are a textbox id named "cal", a dropdown field id named "quantity" and amount field named "amount".

What I want to do is use javascript to do auto calculation when value is changed on the form.

I found there is a javascript tab and there are lots events I could use.

In my case, "formFieldValueChanged" may be useful,

but I don't know how I can get the value from "cal", "quantity" and "amount"?

Could anyone help to give some sample code to let me know how to do this?

In addition, any reference url that I could know more detail on the params of "scope", "form", "field"?
I have read this guide actually Alfresco Activiti, but it seems not mentioned anymore.

Any feedbacks are appreciated and thanks!

BR,

Mandy

1 Solution

Accepted Solutions
gdharley
Intermediate

Re: How to do javascript calculation in the form field

Jump to solution

Hi Mandy,

Based on your most recent inquiry I believe you have found the "helper" function, but as a matter of documentation here it is again:

scope.findFormFieldWithId(scope.allFormFields, 'quantity')

 

This will get you a JSON object and depending on the type of field it is you can retrieve the value, id or name.

Cheers,
Greg 

bp3‌

View solution in original post

3 Replies
gdharley
Intermediate

Re: How to do javascript calculation in the form field

Jump to solution

Hi Mandy,

Based on your most recent inquiry I believe you have found the "helper" function, but as a matter of documentation here it is again:

scope.findFormFieldWithId(scope.allFormFields, 'quantity')

 

This will get you a JSON object and depending on the type of field it is you can retrieve the value, id or name.

Cheers,
Greg 

bp3‌

sprincess
Member II

Re: How to do javascript calculation in the form field

Jump to solution

Many thanks for your kindly feedback.

I found it just by google, but it seems there are lack of information on google.

I wonder to know what is the "helper" function?

May I know where I could find it? thanks!

BR,

Mandy

gdharley
Intermediate

Re: How to do javascript calculation in the form field

Jump to solution

Unfortunately nothing is documented. I had to find all  this by crawling through the source.
There are a few "Helper" functions defined in render-form.js

1. setItemVisibility - runs the visibility logic for the form

2. findFormFieldWithId - locates a specific form field within a collection

3. prepareFormFields - populate data into typeahead, table, dropdown etc from defined REST calls.


Im sure there are others, but since none are documented, it is hard to know what is going to change in the future so have to be careful what you use.

Greg