Home > Domino Tips > Developer > Other > Dynamic redirection after document deletion
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

OTHER

Dynamic redirection after document deletion


Robert Ficek
06.02.2003
Rating: -3.93- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


View member feedback to this tip.

Have you ever wanted to redirect a user to a different page based on what document has been deleted in the database?



Code

1. Create button that will execute 
JavaScript function deleeDoc() (this will 
prompt users if they want to delete 
document) :


function deleteDoc(){
if ( confirm ("Are you sure you want to 
delete this document?")) {
 window.location="http: / /
yourServer/YourDB.nsf/ 
(LookUpView) /" + 
 document.all.item("documentUNID").value + 
 "?deleteDocument&PageNameForRederection" } 
}

2. Create computed for display field with 
formula:
"[<INPUT  TYPE=HIDDEN NAME = 
"documentUNID" VALUE="" + 
@Text(@DocumentUniqueID) + "">]"

This will store your document UNID 
which can be used by JavaScript.

3. Finally, create $$ReturnDocumentDeleted 
form and place this JavaScript in the onLoad event:

arg = document.URL;
pos = arg.indexOf("&");
page = arg.substring(pos+1,arg.length);
setInterval("Countdown(page)", 1000)


Place this script in JSHaeader

function Countdown(page){
  window.location="http: / /
yourServer/yourDB/" + page + 
"?OpenPage"
}

You can place animated gif in the $$ReturnDocumentDeleted (broom or garbage can) and you can also control how long $$ReturnDocumentDeleted will be displayed by modifying parameter in setInterval.

Please make sure that you create Lookup view with first sorted column with formula @Text(@DocumentUniqueID).

This will only work if user opens document in edit mode. If you want to delete document in read mode replace step 1 and 2 with:

1. Create button that will execute JavaScript 
function deleeDoc()- this will prompt users if
 they want to delete document :


function deleteDoc()
{
  if ( confirm ("Are you sure you want to 
delete this document?")) 
  {
        var temp = document.forms[0]
 temp.butDelete.click()
  } 
}


2. Create div tag with delete button, 
which executes formula (div tag hides 
button but it can be executed by JavaScript)


<div id = '@formulaButton' 
style='display:none'>

Your button goes here

</div>

Here is the formula for button:

@URLOpen("http: / /yourServer/
yourDB.nsf/ (DeleteLookup) /" +@Text
(@DocumentUniqueID) + "
?deleteDocument&ViewName")

name button butDelete (HTML TAG, 
Name propriety)

3. Step 3 is the same as in the 
previous section.

You can redirect users to different pages based on document status For example if document has status field, based on its value you can pass different page parameter to $$ReturnDocumentDeleted form.


MEMBER FEEDBACK TO THIS TIP

A neat tip that will be handy if deletion of docs allowed by Web users. However, a view sorted by doc UNID is not required when accessing a document via its UNID. Any view name can be used in the URL, even a non-existant view name -- so use something short like '0'.

-- T Brooks

********************************************

Good tip, another way to simplify the JavaScript for the URL would be:

 var hostname = location.href.split('.nsf'); 

 arg = document.URL;
pos = arg.indexOf("&");
page = arg.substring(pos+1,arg.length);
setInterval("Countdown(page)", 1000)
Place this script in JSHeader:
 
function Countdown(page){
  window.location= hostname[0] + 
".nsf/" + page + "?OpenPage"
}
-- Trevor W.


Do you have comments of your own? Let us know.


Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Other
How to apply XSL style sheets to XML views
Comparing replicas on clustered Lotus Domino servers
Creating a Lotus Notes view column categorized by month
Using the XMLHTTP object for integration with Domino or any RDBMS back end
Hiding field properties/data from DocProperties box
Export a view to Excel without coding
Prevent document deletion if there are response documents
Switching between test IDs quickly
AddParameter to a NotesXSLTransFormer
Using DXL (Domino XML) to review/modify documents

JavaScript for Lotus Notes Domino
Converting Lotus Notes views to XML documents using JavaScript
Mimic Lotus Notes Domino application functionality on the Web
Prevent errors on iFramed pages with JavaScript
Top 10 Lotus Notes Domino programming and development tips of 2007
How to add keyboard functionality for Lotus Notes documents
Validate Lotus Notes Domino fields using JavaScript
How to support Flash objects in any Web browser for a Lotus Notes Domino application
How to validate Lotus Notes forms on a Domino server without losing entered data
A bevy of Notes/Domino development tips
Loading XML from JavaScript

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts