DocumentCollection returned By a View in an Agent

Hey Guys,

I have a problem. Well, let me explain the context. I have an agent running on the server and this agent calls procedures that are located in Script Libraries.

In one of this procedures, I use Db.Search to return a DocumentCollection using a formula. However, it doesn´t return anything (Count = 0). However again, when I create a view with the same formula (this formula does not contain any runtime variables) the view return the correct values. I tried to open that view in the script library instead of using Db.Search. The same problem!

What make me surprised is that I´ve copied the agent code and transform it to a Button (Action) and it works perfectly.

I conclude that some server configuration is set that does not permit the script library to run views ou run incorrectly, I don´t know. What minds is that the server console simple does not give any error, and When I print DC.Count it is always 0 and the script goes correctly. The problem is that it shouldn´t be 0 because there are documents using this criteria and As I said in a button it works, including dc.count

What are my alternatives?

Leandro.

Subject: DocumentCollection returned By a View in an Agent

Wreaks of a permissions or readers issue. Could you have the agent signed with an ID that doesn’t have access to the database, the view, or the documents (via Readers fields)?

The button will run with the ID of the user clicking it in the client, and the agent (if scheduled or “RunOnServer” (agent on a different server?) will run with the ID of the person to last save it, unless it’s “Run as Web User”.

In the agent, when you get the db handle, make sure it’s valid (not nothing) and do the same with the view. If the view is nothing, then it’s permissions.

Jason

Subject: RE: DocumentCollection returned By a View in an Agent

OK…I forgot to say. But before writing this topic, i´ve already made this test. The value of the DB handle and view is “Not Is Nothing”, that means, It is a valid handle with count=0. This is way I´m surprised with the result. So, can I conclude that is not a permission problem?

Subject: RE: DocumentCollection returned By a View in an Agent

Check the db handle was not really my focus. The view variable would be more of interest since it can’t be accessed from the script, even though you built the view. If you can’t get a handle to the view and traverse the documents, then yes it is a permission problem, whether on the agent or the docs.

See if you can catch the exact error message thrown. The text might give us a better clue.

Jason

Subject: RE: DocumentCollection returned By a View in an Agent

OK Jason…

I used db.search and a formula. So I didn´t use a view at first. The problem happened both with db.search or the view with the same formula of db.search

The problem is the documentcollection returned. Running in the agent, the collection return is “Not is Nothing” and the count of this collection is ZERO. And Running in the button, return “Not is Nothing” and more than zero documents. Is This possible??? This is what is happening…

Thank you for your attention.