Confirmation from Server side

Koji Yanase
Tera Contributor

For example, there are 10 records on server table. For each record, it needs confirmation from client user to update the record.

How could I achieve this in UI Action? You can't execute "confirm" in server function. Is any loop between client and server possible?

Thanks.

3 REPLIES 3

sunilsafare
Mega Guru

Hi Koji,



We can achieve this by checking client check box on UI action and write client side script. You can refer below article



Client & Server Code in One UI Action - ServiceNow Guru



Thanks,


Sunil Safare


Hi Sunil,


Thanks for your reply. Can we pass some parameters from client to server? Or in the server side codes, can we pop-up confirmation dialog?


The examples you mentioned are cases that the behavior is fixed on server side. The behavior is not influenced by client instruction.


I'd like to add instructions for each record from client user. Like delete multiple cascade records function. But the Ajax codes are difficult for me. So I'd like to find easy way to achieve this.


Thanks,


Koji


Mike Allen
Mega Sage

I would just do an onSubmit Client Script.   That way, when they hit submit or update, it will run and make them confirm it:


Client Scripts - ServiceNow Wiki


3.2 onSubmit() Scripts

An onSubmit() script runs when a form is submitted. Typically, you use an onSubmit() script to validate things on the form and ensure that the submission makes sense. As such, onSubmit() scripts can potentially cancel a submission by returning false.


An onSubmit() script must contain a function named onSubmit().


For example, here is an onSubmit() script that prompts the user to confirm that a priority one ticket should really be submitted. If the user clicks Cancel in the confirmation dialog box, the submission is canceled.



function onSubmit() { var priority = g_form.getValue('priority'); if (priority && priority == 1) return confirm('Are you sure you want to submit a priority one ticket? The CIO will be notified!');} }


The important thing to remember here is: to stop form submission, return false from your onSubmit() script.