Cancel tiket WO Task
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 01:28 AM
I have a Cancel button but it only changes data for the user display, it should change for the server too,
as in the picture, when I select yes the status will be canceled but not saved, when I refresh or reload the form/browser the status is still work in progress
Please help me
This is the Code :
function cancelTask() {
// Prompt the user for the reason to cancel the task
var reason = prompt("Apakah Anda yakin akan melanjutkan tindakan ini?\nMasukan alasan pembatalan:", "");
// If the user enters a reason
if (reason) {
// Ask for confirmation with the entered reason
var confirmation = confirm("Apakah Anda yakin akan membatalkan dengan alasan: " + reason);
// If the user confirms
if (confirmation) {
// Update ticket fields
g_form.setValue("state", 7);
g_form.setValue("substate", '');
g_form.setValue("work_notes", "Tiket Ini Cancel karena " + reason);
g_form.update();
// Execute server-side processing and handle success/failure
gsftSubmit(null, g_form.getFormElement(), 'cancel_task');
current.update();
action.setRedirectURL(current);
} else {
// Handle cancellation
alert("Pembatalan dibatalkan.");
}
}
}
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 03:43 AM - edited 05-15-2024 03:44 AM
Please try below.
function cancelTask() {
// Prompt the user for the reason to cancel the task
var reason = prompt("Apakah Anda yakin akan melanjutkan tindakan ini?\nMasukan alasan pembatalan:", "");
// If the user enters a reason
if (reason) {
// Ask for confirmation with the entered reason
var confirmation = confirm("Apakah Anda yakin akan membatalkan dengan alasan: " + reason);
// If the user confirms
if (confirmation) {
// Update ticket fields
g_form.setValue("state", 7);
g_form.setValue("substate", '');
g_form.setValue("work_notes", "Tiket Ini Cancel karena " + reason);
// Execute server-side processing and handle success/failure
gsftSubmit(null, g_form.getFormElement(), 'cancel_task');
action.setRedirectURL(current);
} else {
// Handle cancellation
alert("Pembatalan dibatalkan.");
}
}
}
if (typeof window == 'undefined')
serverResolve();
function serverResolve() {
current.incident_state = '7';
current.state = '7';
current.resolved_by = gs.getUserID();
current.update();
}
Please mark my answer correct and helpful if this works for you.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 11:10 PM
not Working bro