Cancle and OK button in Business Rule

Ujjwal1
Tera Contributor

hi,

i need to add alert with Cancel and Ok  button on change of state on incident table.

please  suggest on implementing confirmation , via Business rule.

 

Thanks  

2 REPLIES 2

Runjay Patel
Giga Sage

HI @Ujjwal1 ,

 

You can achieve it via client script. Business rule runs at server end so we can not alert it.

Use below code in onchange client script on state.

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == oldValue) {
        return;
    }

    var answer = confirm("Are you sure you want to change the state?");
    
    if (!answer) {
        // If user clicks "Cancel", revert to the previous value
        g_form.setValue('state', oldValue);
    }
}

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

In this video i have explained about Web service integration in ServiceNow like how it works, how we can configure it, what are the prerequisite and many more. I have covered below topics in this video. 1. understand Web Service. Like when and how we will use it. 2. Talked about Inbound and ...

Viraj Hudlikar
Giga Sage

@Ujjwal1  - BR is for server scripting what you asking is more towards client side scripting so you would need to create a onsubmit client script.

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

Thanks & Regards
Viraj Hudlikar.