Mileage Reimbursement Calculation

100 views
Skip to first unread message

fomo...@gmail.com

unread,
Jun 10, 2015, 1:10:58 PM6/10/15
to suppor...@runmyprocess.com
Hello All,

I am brand new to RMP and still trying to figure everything out. A question that I have is how can a make a widget be autofilled on the page and performs a calculation. I have an array widget where the user inputs the destination, distance, and any toll fees for his or her trip. The array is set up with a footer that will show the total distance and toll fees.

I would like to have a widget that will display the amount the user is going to be reimbursed for his or her trip. So it do something like this

total mileage x 0.57 + total toll fees

Any help would be greatly appreciated.

Thanks in advance
David

Murali

unread,
Jun 11, 2015, 6:53:05 AM6/11/15
to suppor...@runmyprocess.com, fomo...@gmail.com, fomo...@gmail.com
Hi David,

Considering the input fields as distance,toll_fee, please include 2 additional columns Total, javascript in your array widget and configure the javascript as 'Listen to variables' : array.distance[P_index],array.toll_fee[P_index]

and include below javascript code to populate the calculated value in Total field.

var test = parseFloat([[array.distance]][P_index]*0.57) + parseFloat([[array.toll_fee]][P_index]);
id_array.id_total[P_index].setText("" + test); 

Additionally reference: http://docs.runmyprocess.com/User_Guide/Development_Environment/Toolbox/Web_Interfaces/Widget/Array_Widget

Hope this helps.

Regards,
Murali

fomo...@gmail.com

unread,
Jun 11, 2015, 11:03:46 AM6/11/15
to suppor...@runmyprocess.com, fomo...@gmail.com
Thanks for the info, I tried what you put and looked at the page you linked and I can not get it to work. To help us both out here are the names of my variables.

array variable= array_mileage
mileage column variable= distance_travled, type of widget is Number Input, footer variable = totalm
toll column variable= toll, type of widget is Number Input, variable = totalt

The two new columns I created based on the last post
1st column variable= Calculatedm, type of widget is JavaScript, set to listen to array_mileage.distance_travled[P_index]

2nd column variable= Calculatedt, type of widget is JavaScript, set to listen to array_mileage.toll[P_index]

I edited the javascript code to,
vartest=parseFloat([[array_mileage.distance_travled]][P_index]*0.57)+parseFloat([[array_mileage.toll]][P_index]);
id_array.id_total[P_index].setText(""+test);

Thanks in Advance
David

Murali

unread,
Jun 12, 2015, 12:05:56 PM6/12/15
to suppor...@runmyprocess.com, fomo...@gmail.com, fomo...@gmail.com
Hi David,

Attached are the configurations for the sample code provided in earlier response for better understanding.
In this scenario, Total value should change when both or either of distance, toll_fee changes.

Let us know, if you are able to configure as per requirement and try some random alert statements to debug, understand the flow.

Regards,
Murali
Array Widget - JS - Listen to Variables -config.png

Murali

unread,
Jun 12, 2015, 12:20:49 PM6/12/15
to suppor...@runmyprocess.com, mkumma...@runmyprocess.com, fomo...@gmail.com
Reply all
Reply to author
Forward
0 new messages