Hi Audrey,
This may not be the prettiest solution, but I did get it to work.
First create two visible date fields "order_date" and "required_date".
Then set up two hidden fields "order_date_num" [numeric field] and "required_date_check" [date field].
The "order_date" field does not have any script.
The "order_date_num" field has the following Formcalc in the calculate event (this converts the date to a number):
b $ = Date2Num(order_date.rawValue, "YYYY-MM-DD", "en_IE")
The "required_date_check" has the following Formcalc in the calculate event (this adds 14 days to the number [if the order_date is not empty] and converts it back to a date):
b if (HasValue(order_date_num)) then
b $ = Num2Date(order_date_num.rawValue + 14, "YYYY-MM-DD", "en_IE")
b else $ = null
b endif
The "required_date" field has the same Formcalc in the calculate event (this auto populates the Required Date field to 14 days time, prompting the user):
b if (HasValue(order_date_num)) then
b $ = Num2Date(order_date_num.rawValue + 14, "YYYY-MM-DD", "en_IE")
b else $ = null
b endif
I set the "required_date" field to calculated, but user can overide, so the last script is needed to prevent the user setting a date sooner than 14 days. The Javascript is in the "required_date" exit event (this checks the value at exit to the "required_date_check" valua and if less than 14 days, throws up a warning and resets the date to 14 days):
b if (this.rawValue < required_date_check.rawValue)
b {
b app.alert({
b cMsg: "WARNING - Check Required Date.\n\n The required date must be b at least two weeks after the Order Date.",
b cTitle: "YOUR ORGANISATION",
b nIcon: 1, nType: 0
b });
b this.rawValue = required_date_check.rawValue;
b }
Hope this helps! It may be possible to achieve the same effect in less steps, but that is beyond me.
Regards,
Niall