This is more of a usability issue, most of the "Create" agents rely on a selected document and when jumping into the application and clicking Create->Person (for example), you may get the error "Agent failed, To run this agent you must at least one document selected"…
Below is a mod I made to the one of these agents… The agent property should also be changed so that the "Target" is None (instead of Selected Document)… This does a few things:
- Allows agent to be utilized for ALL creation scenerios (clean or inherited values)
- Prevent errors when no doc is selected
NOTE: When the agent is fired from a view or in a document, its "UnProcessedDocument" is the currently highlighted (not really the selected) view document or the currently open document. I left the "dc.count > 1" in there for consistency. (in other selection based agents)… You will typically have 0 or 1 doc in the doc collection…
<snip>
Set dc = this_db.UnprocessedDocuments
If dc.Count > 1 Then
PromptOK("You have selected more than one document from which to create a new document from.")<br/>
Exit Sub<br/>
Elseif dc.Count = 1 Then
'We're getting only the first selected document in the view.<br/>
Set view_doc = dc.GetFirstDocument() <br/>
If Not (view_doc Is Nothing) Then<br/>
cImport = PromptYesNo("Do you want to include information from the currently selected document?")<br/>
End If<br/>
End If
</snip>