Is it possible to get Previous URL in ServiceNow?

Suresh1
Tera Guru

Hi Guys,

 

Is it possible to get previous page URL ? Basically we have a scenario. We have a table say 'problem' and have a related list as 'incident' table. So, if i click on one of related incident it goes to incident table. Here can we get that previous URL / Page belongs to problem record?

We have gs.action.getGlideURI().toString()  which will give current page URL only but cannot give previous page URL.

Let me know if this is feasible.

Thanks,
Suresh

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

You can try:

GlideSession.get().getStack().bottom();

 

This will return something like:

find_real_file.png

View solution in original post

8 REPLIES 8

Allen Andreas
Administrator
Administrator

One way to think about this is how are those records related?

If you're now on an incident record from a related list that was on a problem record, chances are...it's because you have it set to show incidents that have this problem listed on their record, right?

So, you just use a basic URL like: 

var url = "https://instance.service-now.com/task.do?sys_id=" + current.problem_id;

or instead of current.problem_id, if this is a client script, you can use: g_form.getValue('problem_id')

Now you can use url.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

 

May be above use case is not accurate. I have a custom table say 'xyz' and has a reference field called 'incident ' on xyz table. So when i directly open incident record by navigating to incidents and opening particular record, then i have no action/logic to be executed. But when i open the record from the 'xyz' table and clicking on 'i' icon on 'incident' field and then open incident form , then i need to make some logic.

 

Here the trick is how to get the previous page URL. as if i navigate to incident table, i didn't have any common field which points to 'xyz' table to distinguish.

 

Thanks,

Suresh

Anil Shewale
Mega Guru

Hi Suresh

refer the following thread might help you.

https://community.servicenow.com/community?id=community_question&sys_id=e714cfe5dbd8dbc01dcaf3231f96...

 

If it help mark helpful or correct.

Thanks and regards

Anil

Deepen Shah
Kilo Guru
 

If you just want to go back you can use 'history.back();' in client script.

 

Regards
Deepen shah
aavenir.com