- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 08:04 PM
I created a screen
When I click on ‘New’ button than 'Week Start On' be set to the current Manday date.
How should this be implemented specifically?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 08:14 PM
Hi Shiz,
You can achieve that by writing an OnLoad client script for the respective table you are referring.
Here is a sample code you can refer:
function onLoad() {
if (g_form.isNewRecord()) {
var today = new Date();
var day = today.getDay();
// Calculate the Monday of the current week
var monday = new Date(today.setDate(today.getDate() - (day === 0 ? 6 : day - 1)));
g_form.setValue('week_start_on', monday.toISOString().split('T')[0]);
}
}
Thanks,
Pradeep
Regards,
Pradeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2024 08:14 PM
Hi Shiz,
You can achieve that by writing an OnLoad client script for the respective table you are referring.
Here is a sample code you can refer:
function onLoad() {
if (g_form.isNewRecord()) {
var today = new Date();
var day = today.getDay();
// Calculate the Monday of the current week
var monday = new Date(today.setDate(today.getDate() - (day === 0 ? 6 : day - 1)));
g_form.setValue('week_start_on', monday.toISOString().split('T')[0]);
}
}
Thanks,
Pradeep
Regards,
Pradeep