- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2022 10:22 AM
Hello,
If the user selects a past date in the when needed its must throw alert;
but when I select an old record which has an old date in the when field even it gets cleared I don't want to make any changes to the when_needed field for old records,even though the date is in the past.
Should I achieve this through UI or Client script - Please help?
I created a UI Policy as shown below and in the script tab I wrote:
alert('Please select future date');
g_form.clearValue('u_when_needed');
and condition is as shown below = When needed is the date field
I tried this is UI policy script:
but doesnt seem to work------>
function onCondition() {
/*
var ov = g_form.getValue('u_when_needed');
if (ov != "") {
g_form.setValue('u_when_needed',ov);
}*/
alert('Please select future date');
g_form.clearValue('u_when_needed');
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2022 10:55 AM
Hi,
Try creating onChange() client script on "u_when_neede" field with below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var today = formatDate(new Date(),g_user_date_format);
if(g_form.isNewRecord() && newValue < today){
alert('Please select future date');
g_form.clearValue('u_when_needed');
} else {
alert('Please select future date');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2022 10:55 AM
Hi,
Try creating onChange() client script on "u_when_neede" field with below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var today = formatDate(new Date(),g_user_date_format);
if(g_form.isNewRecord() && newValue < today){
alert('Please select future date');
g_form.clearValue('u_when_needed');
} else {
alert('Please select future date');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2022 03:42 PM
Many thanks ! it worked!
But have a question there is no date class in the client side API
where do you refer for such classes and methods like Date(), format date?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2022 08:43 PM
Hi,
Date() is a javascript date object. By default, JavaScript will use the browser's time zone and display a date as a full text string.
Refer below docs for better understanding
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
Please make my response as correct answer or helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 02:52 AM
Excellent! Thanks a lot!