Help with UI page formatter and SN Back Button

JoeBishop-R
Mega Expert

Got a slightly odd problem that I'm not really sure how to investigate any further.

 

We have a custom table structure that uses a lot of assessments to capture information from users across numerous parent/child records. In order to make it easier to view the details of all of the assessments on all of the parent/child records I have built a new formatter. In a nut shell this presents a drop down of all available assessments and lets the user select one to view the answers. This is all working nicely.

 

To get it working I created a formatter linked to a UI macro which is linked to a UI page (we wanted it available on load instead of in a popup accessed via a UI Action). For one reason or another I couldn't get angular loading correctly into the UI macro directly so built it in a UI page instead.

 

The issue I've got presents itself when navigating away from a record with the formatter on to another (usually a child task). When attempting to use the ServiceNow back button to return to the parent from the child task the user is taken to the UI page instead of back to the record.

E.G: http:///now/nav/ui/classic/params/target/ui_page.do%3Fsys_id%3D981eea8y1b18ed1067943a16464bcb10

This only occurs when using the in built back button and not when using the browsers back button instead.

 

I built in a partial solution to detect when the UI page has been loaded outside of an iframe (so has been loaded directly instead of as part of the formatter) however the most I've been able to do is send the user back where they came from. So, in this instance, they arrive back at the child task they were already on instead of the parent and end up in a loop.

 <script type="text/javascript">
        // Check if the page is not embedded within an iframe
		
        if (window.name != '') {			
            // Trigger the browser's back button action
            window.history.back();
        }
</script>

 

This is a very random issue. Has anyone experienced this before and has any idea of how I could prevent the ServiceNow back button interacting with the formatter like this?

 

Thank you.

1 ACCEPTED SOLUTION

JoeBishop-R
Mega Expert

On the off chance someone comes across this in the future. I was unaware that it was possible to put a parameter in the URL to prevent it being added to the navigation stack: sysparm_nostack=true

 

By adding this into UI Page URL being used in the UI Macro it prevented the iframe being added to the navigation stack and fixed all weird navigation issues using the SN back button.

View solution in original post

1 REPLY 1

JoeBishop-R
Mega Expert

On the off chance someone comes across this in the future. I was unaware that it was possible to put a parameter in the URL to prevent it being added to the navigation stack: sysparm_nostack=true

 

By adding this into UI Page URL being used in the UI Macro it prevented the iframe being added to the navigation stack and fixed all weird navigation issues using the SN back button.