- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2024 09:27 AM
hi everyone,
I have a catolog item in which the duration time difference is calculated and populated when start and end date are picked up. I need a catalog client scripts, I have attached the screen to give you an idea what I need exactly.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 09:12 AM
Hi
The previous code did not work.
I have configured the code below, and it worked as I did want. Just keep in mind that use this code for both start date and end date on variable (not duration)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2024 07:39 AM
Hi @kkrushkov
Thanks for your quick response. I have done what you have suggested in your message. But it did not work. I have also attached the screenshots. Where might I have made a mistake?
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2024 08:16 AM
@A Icen Change the variable name in the on change client script to be the end date or the start date, not the duration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2024 09:12 AM
Hi
The previous code did not work.
I have configured the code below, and it worked as I did want. Just keep in mind that use this code for both start date and end date on variable (not duration)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2024 12:53 AM
var startDateObj = new Date(startDate);
var endDateObj = new Date(endDate);
// Calculate the duration difference in milliseconds
var durationDiff = endDateObj - startDateObj;
// Convert the duration difference to hours
var durationHours = durationDiff / (1000 * 3600); // milliseconds to hours
// Set the calculated duration value to the field
g_form.setValue('duration', durationHours);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 11:19 AM