- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 03:53 AM
Hi,
I have 3 fields on a form as below
Date field and 2 string fields.
When Date selected is tomorrow's date, then other two string fields should be made as read only.
Please let me know how can this be done.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 04:29 AM
Hi Varun,
You can achieve this by using a Client Script, or possibly a UI policy to control this.
You can set a UI policy for the following, for example with the following conditions in the condition builder:
"Datefield1" "after" "current minute"
Best Regardds,
Arron

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 04:25 AM
You could add an onChange script to the date field like this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == '') {
return;
}
var date_field = new Date(getDateFromFormat(newValue, g_user_date_time_format));
var current_date = new Date(new Date().getTime());
if(current_date < date_field){
g_form.setReadOnly('field_one',true);
g_form.setReadOnly('field_two',true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 04:36 AM
I tried this out of curiosity and i found that below line is returning me epoch time, that is 1 jan 70.
var date_field = new Date(getDateFromFormat(newValue, g_user_date_time_format));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 04:43 AM
The getDateFromFormat should return epoch time. You use it because a user may have modified their date format preferences to get a 'sanitized' date in a common format. When wrapped in a new Date object, it should be a standard client date object. This makes it safe for comparison no matter what the user's date time preferences are. There is a more complete explanation here (https://jamesfarrer.com/?id=319😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-17-2017 04:47 AM
Understand thanks.