Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
5 replies
Subscribers
7 subscribers
Views
2791 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
Javascript functions - replacement of calworkdays
bojanb
over 8 years ago
Hi,
I have a problem regarding the calculation of a calworkdays function for two dates on a user form. We are not using SAIL at the moment, so until we upgrade, can you please give us a workaround solution by using javascript functions?
I have tried using the following code (for an on-change event of the date input fields):
if (window.FormAPI.getValue("date1").id !=""){
if (window.FormAPI.getValue("number40").id=="")
{
window.FormAPI.setValue('number40',"");
$('input:submit.submitButton')[0].click();
}
else
{
window.FormAPI.setValue('number40',"");
$('input:submit.submitButton')[1].click();
}
}
What this code does is whenever the user changes the values of the date input forms, the javascript function submits a hidden button and reloads the form (as a chained action) and in the output of the form, the calculation of calworkdays is done, so that when the form reloads, that value will be shown in the '...
OriginalPostID-242887
Discussion posts and replies are publicly visible
0
bojanb
over 8 years ago
...number40' field.
But my problem is that the form doesn't calculate this on the first input of the dates (because it's an on-change event, it only works when the fields are changed - after the first input).
Do you have any suggestions how to solve my problem?
Thank you in advance... BR, Bojan
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
charanrajkrishnap0001
A Score Level 1
over 8 years ago
@bojanb - Give a try in calling the above script in onload function while loading the page.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
bojanb
over 8 years ago
We have previously tried calling this function when loading the page:
var dateID = 'date2';
var dateID2 ='date1';
var AbsenceCA = 'dropdown21';
$('#date_date_' + dateID2 + '_valueDateSingle_fd_component_' + window.FormDesigner.runtimeNamespace + dateID2 +'_').trigger('change');
$('#date_date_' + dateID + '_valueDateSingle_fd_component_' + window.FormDesigner.runtimeNamespace + dateID +'_').trigger('change');
var todate = window.FormAPI.getValue("To_date_value").id;
window.FormAPI.setValue('date2',todate);
var fromdate = window.FormAPI.getValue("From_date_value").id;
window.FormAPI.setValue('date1',fromdate);
But when loading the page, the process goes into a long loop (reloading the page over and over...because the onload function triggers the onchange event of the date input fields...
Initially, I want the values to be empty so that the user must input them (so that there are no mistakes when filling the form).
Do you have any other idea or advice?
Thank you again... BR
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
charanrajkrishnap0001
A Score Level 1
over 8 years ago
@bojanb: Instead of OnChange Event, try to trigger with oninput (or) onmousemove Event.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
bojanb
over 8 years ago
The Date field only has change event. I tried using the "input" trigger in the load function (in the code that I previously wrote), but still - nothing happened.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel