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
19 replies
Subscribers
8 subscribers
Views
5939 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
What is wrong with following event ajax call ffrom form on chanhe od date field
natasav
over 12 years ago
What is wrong with following event ajax call ffrom form on chanhe od date field ?
window.FormAPI.evaluateServerSideExpression(function(fn){
window.FormAPI.setValue("number41",fn);
},"=calworkdays(FormAPI.getValue("date1").id, FormAPI.getValue("date2").id])");
OriginalPostID-23033
OriginalPostID-23033
Discussion posts and replies are publicly visible
0
natasav
over 12 years ago
Hi Eduardo,
you only add rules at load and on change on date2. I have copy your JS function in my environment and no meter what date I select count duration is always 1. Should I do something else maybe I need to add more JS rules on the form.
And it need to be trigger on any change of From Date and To Date even the first one from nothing to date.
Best Regards, Natasa
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
natasav
over 12 years ago
The field_id for duration is changed because I add and remove this field.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
natasav
over 12 years ago
I even try and import your form in one simple process with only user input task and test it the result is the same no meter what date I select duration is 1.Just to confirm that form that use is not so special, als JS file that I call is that has function for validation of to date not be selected before from date (Negative duration)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 12 years ago
Good catch. This type of issues can be easily diagnosed using Fiddler to monitor the request you are doing. If you take a look at the request: http://<SERVER>/suite/plugins/servlet/forms_expression in Fiddler you will see the expression is sent as: expression%3D%3Dcalworkdays(2%2F1%2F2012%2C2%2F7%2F2012) which can be decoded using this site:
meyerweb.com/.../
When decoded you will see the expression we are evaluating is of type:expression==calworkdays(2/1/2012,2/7/2012) which is not correct, because there are no quotes surrounding the dates. If you test this directly in the Rules interface it will give you the wrong value too.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 12 years ago
The solution is changing the JS to make sure the dates are enclosed in quotes:
FormAPI.evaluateServerSideExpression(function(e){debugger; window.FormAPI.setValue('number41',e);},'=calworkdays("' + FormAPI.getValue('date1').id + '","' + FormAPI.getValue('date2').id +'")');
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 12 years ago
Here's the updated example (exported form):
forum.appian.com/.../36837
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 12 years ago
After this change Fiddler will show the right expression in the request: expression=%3Dcalworkdays(%222%2F1%2F2012%22%2C%222%2F7%2F2012%22) which decoded looks like this: expression==calworkdays("2/1/2012","2/7/2012") with the parameters in quotes.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
vineeta6579
over 11 years ago
HI eduardo
How i can set 3 fields with the given JS code.
Suppose i have number41,number42,number43 fields...
FormAPI.evaluateServerSideExpression(function(e){window.FormAPI.setValue("number41",e);},
"=calworkdays(" + FormAPI.getValue("date1").id + "," + FormAPI.getValue("date2").id +")");
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 11 years ago
If the result of your calworkdays expression is supposed to be used to set number41, number42, number43 just add the corresponding setValues after window.FormAPI.setValue("number41",e); separating each statement with a semicolon for instance:
FormAPI.evaluateServerSideExpression(function(e){window.FormAPI.setValue("number41",e);window.FormAPI.setValue("number42",e);window.FormAPI.setValue("number43",e);},
"=calworkdays(" + FormAPI.getValue("date1").id + "," + FormAPI.getValue("date2").id +")");
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
<