smithajohn
asked on
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
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
Sorry, a FORM named $$ReturnDocumentDeleted (the help text confused me a bit)
cheers,
Tom
cheers,
Tom
Hi Bozzie4,
Hmm, I wonder if a simple $$Return would work -- @COmmand([EditClear]); @Command([OpenView]; "default view name")
Best regards,
qwaletee
Hmm, I wonder if a simple $$Return would work -- @COmmand([EditClear]); @Command([OpenView]; "default view name")
Best regards,
qwaletee
No that doesn't work , I just tried it. Maybe if the formula is rewritten to something more complex ...
cheers,
Tom
cheers,
Tom
ASKER
Hi Bozzie4,
I also went thru the help and did the same mistake as you said($$ReturnDocumentDelet ed 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..
I also went thru the help and did the same mistake as you said($$ReturnDocumentDelet
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..
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(instr uct)
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
Instead of using a button with the @Command, use a link to the following computed URL:
"/" + @ReplaceSUbstring(@Subset(
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(instr
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
Or put this in the htmlhead section of the Form :
"<meta http-equiv=\"refresh\" content=\"1;url=/"+ @webdbname++"/theview?open view\">"
This will redirect the user automatically to the view. Not a perfect solution, but at least easy to do :-)
cheers,
Tom
"<meta http-equiv=\"refresh\" content=\"1;url=/"+ @webdbname++"/theview?open
This will redirect the user automatically to the view. Not a perfect solution, but at least easy to do :-)
cheers,
Tom
Well, heck, you could just give the "$$ViewTemplateFor [main view name]" form an alias -- $$ReturnDocumentDeleted
Wouldn't that be even simpler?
Wouldn't that be even simpler?
ASKER
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="...?openvie w". 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.
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="...?openvie
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.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
thanks, I'll try it out....
ASKER
Thanks qwaletee ....
So you get 125+100=225 points !!
So you get 125+100=225 points !!
$$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 $$ReturnAuthenticationFail
@If(@Contains(messagestrin