
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2023 01:41 AM
Hello All
I would like to have a button to reset a value type glide_duration in the ast_service table.
I have written the below code but it doesn't work, value doesn't reset
function ResetYearlyChangeHoursFunction() {
//g_form.setValue('u_used_yearly_change_hours','0 00:00:00');
var zero = gs.getDurationDate('0 0:0:0');
var usedHours = current.u_used_yearly_change_hours;
usedHours = '0 0:0:0';
//current.u_used_yearly_change_hours = zero;
//g_form.clearValue('u_used_yearly_change_hours');
action.setRedirectURL(current);
gs.addInfoMessage("Used Yealy Change Hours are now back to zero");
}
Can someone help me ? 🙂
Thanks!
Jérôme
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2023 02:05 AM
Hi @Jerome MAISETTI ,
It seems like the code you've written doesn't actually update the 'u_used_yearly_change_hours'field with the new duration value. You have only defined a variable zero with the value of 0 duration, and then set the 'usedHours' variable to the string '0 0:0:0'.
To actually reset the value of the "u_used_yearly_change_hours" field, you can try the following code:
function ResetYearlyChangeHoursFunction() {
// Get 0 duration value
var zeroDuration = gs.getDuration('0 0:0:0');
// Set the value of u_used_yearly_change_hours to 0 duration
current.u_used_yearly_change_hours = zeroDuration;
current.update();
// Redirect to the same record to refresh the UI
action.setRedirectURL(current);
gs.addInfoMessage("Used Yearly Change Hours have been reset to zero.");
}
In this updated code, we first use the 'gs.getDuration()' method to get the 0 duration value. Then, we set the 'u_used_yearly_change_hours' field on the current record to this 0 duration value and save the record using current.update(). Finally, we redirect to the same record to refresh the UI and display the success message.
Regards,
Shravan
Shravan
Please mark this as helpful and correct answer, if this helps you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2023 02:05 AM
Hi @Jerome MAISETTI ,
It seems like the code you've written doesn't actually update the 'u_used_yearly_change_hours'field with the new duration value. You have only defined a variable zero with the value of 0 duration, and then set the 'usedHours' variable to the string '0 0:0:0'.
To actually reset the value of the "u_used_yearly_change_hours" field, you can try the following code:
function ResetYearlyChangeHoursFunction() {
// Get 0 duration value
var zeroDuration = gs.getDuration('0 0:0:0');
// Set the value of u_used_yearly_change_hours to 0 duration
current.u_used_yearly_change_hours = zeroDuration;
current.update();
// Redirect to the same record to refresh the UI
action.setRedirectURL(current);
gs.addInfoMessage("Used Yearly Change Hours have been reset to zero.");
}
In this updated code, we first use the 'gs.getDuration()' method to get the 0 duration value. Then, we set the 'u_used_yearly_change_hours' field on the current record to this 0 duration value and save the record using current.update(). Finally, we redirect to the same record to refresh the UI and display the success message.
Regards,
Shravan
Shravan
Please mark this as helpful and correct answer, if this helps you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2023 03:06 AM
Thanks a lot! That worked 🙂