Manage Learn to apply best practices and optimize your operations.

Return to view after document is closed

If you have multiple views that link to the same documents, it can be convenient to return a user to the view they used to open a document when the document is submitted or closed.

View member feedback to this tip.

If you have multiple views that link to the same documents, it can be convenient to return a user to the view they used to open a document when the document is submitted or closed.

One way to do this is to set the view name in the cookie whenever you leave the view, then use the cookie to reopen the last view by invoking some JavaScript to go to the last view.

In the onunload event of the $$ViewTemplate form, add the following code:

document.cookie = "lastView=" + 
escape (document.location)+";path=/";

Add the following functions to a script library or JSHeader:

function bk() {
 var lastView =GetCookie("lastView");
 if (lastView) {top.document.location=
lastView; return}
 history.go(-2);
}

function getCookieVal (offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1) { endstr = 
document.cookie.length; }
 return unescape(document.
cookie.substring(offset, endstr));
 }
 
function GetCookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg) {
   return getCookieVal (j);
   }
  i = document.cookie.indexOf(" ", i) + 1;
  if (i == 0) break; 
  }
 return null;
 }

In the $$Return field, a cancel button, or another action, calls the "bk()" function. For example, you could put the following in the $$Return field: <script>bk();</script>

MEMBER FEEDBACK TO THIS TIP

I prefer a different technique that doesn't require a cookie. When creating the link to open the document, add a URL parameter containing the name of the $$ViewTemplate alias. For example:

&form=
 
  . You can do this in a view column definition of the embedded view.

 

When creating the $$Return for the newly opened document use @UrlQueryString("form") to code the return link to open the calling form -- no cookie needed. For example:

$$Return (set FormName to the URL 
Parameter value &form=) 
"&ltSCRIPT language=\"JavaScript\
"&gtjavascript:window.location=\"http://" + 
Server_Name + "/" + dbName + "/" + FormName +
 "?OpenForm"+ "\"</SCRIPT>"

—Douglas F.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Chad Cole. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on JavaScript for Lotus Notes Domino

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close