Redirection in client script

Shanthi10
Kilo Contributor

Hi All,

When a specific field value changes, we have to show a popup box with a message. When the user clicks on OK, user should be redirected to service portal page i.e., "/sp"

I have written an onchange client script to perform the following

I am able to see the popup-box with the required message. When I click on OK, I am getting an extra dialog box and based on the user input as "Leave" the redirection to service portal page is happening

Need help to remove the extra dialog box.

 

Steps to reproduce the issue

find_real_file.png

I have written Onchange on the description field. Code is as follows

find_real_file.png

Upon filling the description field, I am getting the following popup-box

find_real_file.png

Onclick of OK, I am getting the following message

find_real_file.png

 

On click of Leave, redirection to serviceportal home page happens.

As per the requirement, On click of OK, the user should be redirected to service portal home page directly without extra dialog box. Need inputs on removing the extra dialog box which is "Leave Site?" in my screenshots attached.

Appreciate the great help. 

 

2 REPLIES 2

Oleg
Mega Sage

First of all, I'd recommend you to verify that there are exist no onLoad or onChange script, which changes the data without previously testing, that new value are exactly the same as new one. I mean that you could have unneeded call of g_form.setValue, which invalidate the field. It's better to use g_form.getValue always before g_form.setValue and call g_form.setValue only is the setting value is different as existing one.

Another possibility: you know that some data are changed on catalog item and you want ignore the changes and redirect to another page. In the case you can call g_form.$private.userState.clearModifiedFields(); to clean internal _userModifiedFields object of GlideForm, which hold the list of modified fields.

Sandhya V
Tera Contributor

Thanks @Oleg  This was helpful.