Service Portal - Disable Leave Site?

ah16
Mega Expert

Hi,

I cloned form widget and keeps getting this leave site alert when I'm trying to click on save button of the form.

Any suggestions to get rid of this alert?

 

find_real_file.png

1 ACCEPTED SOLUTION

Hi,

on form we can get to know which fields got changed. but that is difficult on portal

can you try this just before navigation

window.onbeforeunload = function () {
  // blank function do nothing
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Thanks Ankur. Based on the selections, we do hide lot of fields. Is there a way to identify which fields have changed after load?

We do use the same form on platform and didn't see any issues.

 

Hi,

on form we can get to know which fields got changed. but that is difficult on portal

can you try this just before navigation

window.onbeforeunload = function () {
  // blank function do nothing
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ankur, that didn't worked but I think it might be 'Seconds part of Duration field type which I'm hiding on the UI.

#dur-seconds-u_start_date_of_activity {
display: none;
}

I don't see this alert when I used OOTB Form Widget. How can I fix this?

 

find_real_file.png

 


<input type="text" class="form-control ng-valid ng-not-empty ng-dirty ng-valid-parse ng-touched"
id="dur-hours-u_start_date_of_activity" ng-model="parts[unit]" ng-disabled="field.isReadonly()"
ngchange="updateDuration()" title="Hours" role="textbox" aria-invalid="false" style="">

 

<input type="text" class="form-control ng-valid ng-not-empty ng-dirty ng-valid-parse ng-touched"
id="dur-minutes-u_start_date_of_activity" ng-model="parts[unit]" ng-disabled="field.isReadonly()"
ng-change="updateDuration()" title="Minutes" role="textbox" aria-invalid="false" style="">

<input type="text" class="form-control ng-pristine ng-untouched ng-valid ng-not-empty"
id="dur-seconds-u_start_date_of_activity" ng-model="parts[unit]" ng-disabled="field.isReadonly()"
ng-change="updateDuration()" title="Seconds" role="textbox" aria-invalid="false">

 

Hi Ankur,

Any other suggestions to fix this alert?

 

Thanks,

Ashraf

 

Thanks, I was able to remove alert after following your suggestion window.onbeforeunload.