• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

After deleting a document in a view, how to redirect the page to the view>

Hi,
   I open a document in a view and delete it with an Action button. The code in the button is @Command([EditClear]). It deletes the document. My problem is, it gives me a page saying 'Deleted'. But I want the parent view to be displayed and refreshed instead of this page. I've a $$Return field in the form which directs the control to the view. But it works with Submit action only.
 Thanks in advance
0
smithajohn
Asked:
smithajohn
  • 4
  • 4
  • 4
1 Solution
 
Bozzie4Commented:
Yes, you can use another $$ field  for this.

$$ReturnDocumentDeleted

This is from designer help :
Adding the message field
Create one of the following fields to hold the error message:
An editable text field named MessageString to display the default server-generated error message.
A computed-for-display field whose formula replaces the default error message with a customized message.
For example, this formula for a field named CustomString on a $$ReturnAuthenticationFailure form gives more information to the user if authentication fails. The formula takes the value from the default MessageString field if it contains "unauthenticated" and replaces it with instructions to the user. If the MessageString field does not contain the word "unauthenticated", Domino uses the value of MessageString instead.
@If(@Contains(messagestring;"unauthenticated");"Sorry, the name and password you entered are unknown in our system. If you are new to our site, return to the home page and follow instructions for registering.";messagestring)

0
 
Bozzie4Commented:
Sorry, a FORM named $$ReturnDocumentDeleted (the help text confused me a bit)

cheers,

Tom
0
 
qwaleteeCommented:
Hi Bozzie4,

Hmm, I wonder if a simple $$Return would work -- @COmmand([EditClear]); @Command([OpenView]; "default view name")

Best regards,
qwaletee
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Bozzie4Commented:
No that doesn't work , I just tried it.  Maybe if the formula is rewritten to something more complex ...

cheers,

Tom
0
 
smithajohnAuthor Commented:
Hi Bozzie4,
    I also went thru the help and did the same mistake as you said($$ReturnDocumentDeleted field).
I tried it with $$ReturnDocumentDeleted form. When the doc is deleted succesfully, my MessageString will be empty.
I've given ' @If(MessageString="" ; "http://.../"viewname"?Openview" ; MessageString) ' in the formula field. Is this the way?
Instead of the "Deleted" page it gives me a page with a link to the View. I tried @Command([OpenView]) in the @If , but it doesn't work.
Any way to to goto the view directly as in $$Return field?
thanks..
0
 
qwaleteeCommented:
What might work better for you...

Instead of using a button with the @Command, use a link to the following computed URL:
    "/" + @ReplaceSUbstring(@Subset(@DbName;-1); " " : "\\"; "+" : "/") + "/DeleetDocument?OpenAgent&" + @Text(@DocumentUniqueID)

Create an agent:
    named DeleteDocument
    Shared
    set to run with web user's rights
    Run against No target or Run Once (@Commands may be used)
    Using LotusScript
    Place the following code in Initialize

Dim s as new notesSession
Dimc control as notesDocument, db as notesDatabase, target as notesDocument, pos as integer,insruct as String
Set control = s.documentContext
Set db = s.currentDatabase
instruct = control.Query_String(0)
pos = Instr(instruct,"&")
If pos = 0 Then
    Print "Missing document delete instruction"
    Exit Sub
End If
instruct = Mid$(instruct,pos+1)
If Len(instruct) <> 32 Then
    Print "Invalid document delete instruction"
    Exit Sub
End If
On Error Resume Next
Set target = db.getDocumentByUnid(instruct)
If Err <> 0 Then
    Print "Unknown document delete instruction " Erl Err Error
    Exit Sub
End If
target.Remove
If Err <> 0 Then
    Print "Failed document delete instruction " Erl Err Error
Else
    Print "[..]" 'redirect to database home page
End If



0
 
Bozzie4Commented:
Or put this in the htmlhead section of the Form :

"<meta http-equiv=\"refresh\" content=\"1;url=/"+ @webdbname++"/theview?openview\">"

This will redirect the user automatically to the view.  Not a perfect solution, but at least easy to do :-)


cheers,

Tom
0
 
qwaleteeCommented:
Well, heck, you could just give the "$$ViewTemplateFor [main view name]" form an alias -- $$ReturnDocumentDeleted

Wouldn't that be even simpler?
0
 
smithajohnAuthor Commented:
qwaletee ,
       Loads of thanks for that. The agent is working fine.

Bozzie4,
     The HTML head code doesn't seem to be working. It will take the control back to the view even before I click the "Delete' button.
and in the load event of $$ReturnDeleteDocument , u can give location.href="...?openview". It will also redirects to the view instead of giving the link(when u use the computed field and Messagestring, it gives a page with a link to the view).

      But there is another bottleneck now...I want to give this delete option in many views. How do I get the viewnames in a global variable? so that I can use this variable in the agent.
I tried it in the Global section of the view(getview). But it returns an empty string.
I invoke the views thru Hotspont links from the navigation page.

Will give another 100 points for this....

thanks.
 
0
 
qwaleteeCommented:
You don't need to know every view.  If you use HTTP_REFERER, you can use the prior URL to get the view name or view UNID, and just redirect to that.

For example, if the document opened via
    http://server/folder/file.nsf/0123456789abcdeffedcba9876543210?OpenDocument
then you just pull off the
    http://server/folder/file.nsf/0123456789abcdeffedcba9876543210
as the view URL.  The view UNID is 0123456789abcdeffedcba9876543210, and that URL alone is enough (you can append ?OpenView if you wish).

Sometimes the document URL will change as it is being edited, or may have additional parameters of some other sort.  The following will stil work:

    http://server/folder/file.nsf/0123456789abcdeffedcba9876543210?OpenDocument&Seq=7&RestricToCategory=Qwaletee+Category
still resolves properly to view URL
    http://server/folder/file.nsf/0123456789abcdeffedcba9876543210
0
 
smithajohnAuthor Commented:
thanks, I'll try it out....
0
 
smithajohnAuthor Commented:
Thanks   qwaletee ....
So you get 125+100=225 points !!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now