How can I change the state canceled when user click on cancel ui action?

Community Alums
Not applicable

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

3 REPLIES 3

Murthy Ch
Giga Sage

Hi 

Can you try like this:

find_real_file.png

find_real_file.png

(current.state!=7&&current.state!=8)&&current.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

Thanks,
Murthy

shloke04
Kilo Patron

Hi Preeti & @Murthy ,

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);

find_real_file.png

This is working for me in my PDI. Let me know if you are facing an issue here.

Before button is clicked:

find_real_file.png

 

Final Result after button is clicked, state changes to Canceled and button is also not visible on the form:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thanks for your suggestion:)

Thanks,
Murthy