How to calculate days difference between two Dates variable & display the result in the text field?

1
0
-1

I am trying to calculate difference between two dates and display the days difference in text field using Bonita BPM Community 7 Version 7.3.1. I am new to Bonita give me some idea that on which event i have to calculate Date difference and display in text field. There is no onselect like events for input type Date in Bonita?

1 answer

1
0
-1

You're right. Bonitasoft don't allow us the ability to give names to widgets which would allow us this facility with a piece of JavaScript.

Please add your voice to the following post in ideas so that we can get this facility:
http://community.bonitasoft.com/ideas/give-developers-ability-add-ids-fo...

In this case the only option I can suggest is to create a Custom Widget that will allow you to do this.

You could in fact combine all three fields into one widget so they are grouped and can be reused where necessary. Something like:

<div>
<input id="datefield1">datefield1</input>
<input id="datefield2">datefield2</input>
<input id="No-of-Days">No-of-Days</input>
</div>

onchange("datefield2"){
//for setting start and end dates
stopevents;
No-of-Days=datefield2-datefield1+1; //+1 for same day start and end
startevents;
}

onchange("No-of-Days"){
//for setting start and No-of-Days (ex. start date of holiday and I want 10 days off)
stopevents;
datefield2=datefield1+No-of-Days+regulatory(); //make sure you add weekends and other holidays as appropriate - function regulatory
startevents;
}

Hope this helps

regards
Seán

PS: As this reply answers your question, please mark a resolved by clicking the tick mark on the left.

Notifications