How can I change the state canceled when user click on cancel ui action?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2022 08:35 PM
Hi,
My requirement is a cancel ui action should be on incident form when user submit the incident and then user will be able to click on cancel button then when user submit the incident form through cancel button incident state should be canceled and this button should be there when user open that incident which he created such as resolve, update, delete and it should be visible for only those users who created the incident. How can I achieve this requirement.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2022 09:38 PM
Hi
Can you try like this:
(current.state!=7&¤t.state!=8)&¤t.caller_id==gs.getUserID();
function cancelincident() {
alert("You are cancelling the incident");
gsftSubmit(null, g_form.getFormElement(), 'cancel_inc');
}
if (typeof window == "undefined")
cancellingincident();
function cancellingincident() {
current.state = 8;
current.work_notes = "Cancelled this incident";
current.update();
action.setRedirectURL(current);
}
(=tested)
Thanks
Murthy
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 03:37 AM
Hi Preeti &
What you have suggested looks partially correct to me. Reason being if you look at the scenario which Pretty has mentioned she is saying the button should be visible only to those who have created the Incident.
So checking based on Caller of the Incident will not work here, as someone can create an Incident on some one else behalf and there can be a scenario that caller and opened by wither both should have this flexibility or only Caller
Pretty you can confirm here, I am adding both the condition to the UI Action so that both Opened By and Caller should have rights to Cancel the ticket
Also another important thing to check here is if the user who is trying to cancel a ticket has a permission enabled for him or not if he can cancel the ticket or not. If you do not evaluate this then even if you display the button and user clicks on it, nothing will happen and your button will not work properly
Please use the UI Action and script below for reference:
Condition of UI Action:
current.canWrite() && (current.caller_id == gs.getUserID() || current.opened_by == gs.getUserID()) && current.state!=8
Script of UI Action:
current.state = 8;
current.update();
action.setRedirectURL(current);
This is working for me in my PDI. Let me know if you are facing an issue here.
Before button is clicked:
Final Result after button is clicked, state changes to Canceled and button is also not visible on the form:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2022 10:30 PM
Thanks for your suggestion:)
Murthy