-1

I have a Search input box and an agent which exports the view. If I click export (not typing anything in the Search input box) it will all documents in the view. But for example I input "ABC" in the input box and click Search, it will list in the view all the documents which is under "ABC" but when I clicked export, it doesn't export the view.

I want to know how to access the filtered view which corresponds to the value in the Search input box so I can export the filtered documents in the view.

Thanks.

Here is part of the whole agent code:

    Redim colnumbers (0 To 100) As Integer
Set db=session.currentdatabase
Set doc=session.DocumentContext
expview=Strright(doc.query_string_decoded(0),"expview=")
Dim query As String
query = Strleft(Strright(doc.query_string_decoded(0),"query="),"&expview=")
'Print query + expview

filename="Excel "+db.Title+" "+Format(Now, "yyyy-mmm-d hh-mm")+".xls" 'file name which will be suggested to user to save the resulting Excel file
tmp=""

If Instr(doc.query_string_decoded(0),"expview=")=0 Then ' find out if view is supplied as URL parameter to this agent
Set view = db.GetView("RPG") ' no view supplied as parameter, use your default export view

Else
    'expview=StrRight(doc.query_string_decoded(0),"expview=")
    If Instr(expview,"&")>0 Then expview=StrLeft(expview,"&")
    Set view = db.GetView(expview) ' get the view passed as parameter to the agent
End If

If view Is Nothing Then
    Print "Export Error - Export view does not exist"
    Exit Sub
End If
Ragome
  • 55
  • 2
  • 12
  • Can you please post the regarding part of your code, for more information. – OliC May 08 '14 at 07:01
  • Hi, I posted the part of the code in the question. Thanks. – Ragome May 08 '14 at 07:38
  • Just an information for everyone who did not follow the "original" question: This is the revival of a question that had been asked some days ago and then "disappeared" (don't know, if deleted by questioner or voted to be deleted). That's why I already know a little more about the background... – Tode May 08 '14 at 09:17
  • I voted down the question, because it lacks a lot of information that is needed to correctly answer the question... – Tode May 08 '14 at 09:35

1 Answers1

0

Additional info to the question (this is something that clearly needs to be in the question itself, but Ragome does not seem to think it is important): This is a code of an agent, that is called from a web- button with @URLOpen( .../AgentName?OpenAgent&expview=" + @Subset( @ViewTitle ; 1 ) )

The problem is: As long as the view is not filtered, it is actually a view showing in the browser. As soon as you filter a view with a search, it is a form that is displayed. This form is named $$SearchTemplateDefault or $$SearchTemplate for YourViewTitle

If you want to access the "found" documents with a backend- agent, then you need to create your own $$SearchTemplate- Form and create a field, that contains the UniversalId of every result. Then you can "hand over" the document to the agent using ses.DocumentContext. There you read the universalids and work on the corresponding documents for your export.

Another possibility would be to hand over your searchstring and repeat the search in the backend agent using db.Search( yourQuery ) or db.FTSearch( yourQuery ) depending on the way you search.

As an answer to your question I can just say: there is NO WAY to get a view, that is filtered in the frontend (Browser) as "filtered" backend NotesView- Object in an agent.

Tode
  • 11,795
  • 18
  • 34
  • You mean to say that: @URLOpen( .../AgentName?OpenAgent&expview=" + @Subset( @ViewTitle ; 1 ) ) Is not a correct code? – Ragome May 08 '14 at 09:45
  • No, I mean: This information HAS TO BE IN YOUR QUESTION!!! And if the url to call the agent is computed with another formula, then this has to be there as well! – Tode May 08 '14 at 09:51
  • Would like to ask a few questions to you, how will I be able to contact you? – Ragome May 08 '14 at 10:05
  • 1
    Post your questions publicly, right here. That way everyone learns from your questions and from the answers, not just you! – Richard Schwartz May 08 '14 at 18:52