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
8 subscribers
Views
2280 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
Hello, I have a text field that I validate with a certain JS function (hour
bojanb
over 11 years ago
Hello,
I have a text field that I validate with a certain JS function (hoursValidation()). This function makes multiple validation checks (calls other sub-methods within). One of the sub-functions validates whether the selected date is not more than 2 working days before the current day. I do not know how to correctly call the "calworkdays" function using the FormAPI.evaluateServerSideExpression. Here is part of the code:
...
var earlierdate = new Date(yearfrom,monthfrom-1,datefrom);
var laterdate = new Date(yearto,monthto-1,dateto);
var daysDifference = FormAPI.evaluateServerSideExpression(function(fn) {return fn;},["calworkdays",'earlierdate','laterdate');
if(daysDifference <= 2)
{
return true;
}else{
return false;
}
Please tell me if you have any suggestions about properly using the "calworkdays" function within the FormAPI.evaluateServerSideExpression. The function expects 2 input parameters (in this case - "earlierdate" and "laterdate"). Than...
OriginalPostID-68197
OriginalPostID-68197
Discussion posts and replies are publicly visible
0
bojanb
over 11 years ago
...k you in advance.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Ravichandran Thiruganasambandham (Ravi Sam)
Certified Lead Developer
over 11 years ago
Can you try passing in the appian date object directly to the expression instead of the one converted to JS format.
For Example:
var startdate = FormAPI.getValue("StartDate").id;
var enddate = FormAPI.getValue("EndDate").id;
FormAPI.evaluateServerSideExpression(function(fn) {return fn;},["calworkdays",startdate,enddate);
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
bojanb
over 11 years ago
Hi,
I've tried your suggestion, but I still do not get a correct result - my validation doesn't work. I do not know if i am properly using the "calworkdays" function within the FormAPI.evaluateServerSideExpression.
var daysDifference = FormAPI.evaluateServerSideExpression(function(fn) {return fn;},["calworkdays",startdate,enddate]);
Do I need the first part: function(fn) {return fn;} ???
Thank you in advance... BR
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Ravichandran Thiruganasambandham (Ravi Sam)
Certified Lead Developer
over 11 years ago
Sorry i gave a wrong syntax, here is the correct syntax.Please use this
var startdate = FormAPI.getValue("startDate").id;
var enddate = FormAPI.getValue("endDate").id;
FormAPI.evaluateServerSideExpression(function(fn) {alert(fn);},["calworkdays",startdate,enddate]);
hope this helps.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
bojanb
over 11 years ago
THANK YOU VERY MUCH!!! It works - it alerts me about the day difference. But when I try to save the result into a variable, it doesn't work for me. I am using this code:
var daysDifference = FormAPI.evaluateServerSideExpression(function(fn) {return (fn - 1);},["calworkdays",date1,date2]);
i also tried:
var daysDifference;
FormAPI.evaluateServerSideExpression(function(fn) {daysDifference = fn -1; },["calworkdays",date1,date2]);
I need the result for the validation (if it's bigger than 2 days, the function should return false, otherwise - true).
Thank you in advance... BR
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel