1

I have the following situation:

  1. The mask Person has a embedded view with documents of form Notes (notes about the person).
  2. The mask Person has a Person_ID field.

I need an action in the embedded view that do the following actions:

  1. Creates a new Notes document.
  2. Reads the field Person_ID from the mask where the view is embedded.
  3. Stores the value in the new created document in the field Notes_Refto.
  4. Opens the new document in the edit mask.

Best regards Robert

Robert Moszczynski
  • 1,081
  • 2
  • 16
  • 26

2 Answers2

2

Add this button to your form Person, not into the embedded view. You can position the button right above or beneath the embedded view.

Let the new document inherit fields from Person document like the Person_ID field.

Knut Herrmann
  • 30,880
  • 4
  • 31
  • 67
  • Ok, perfect! The next problem I have is that the new opened document cannot be saved. No message is displayed, nothing happens and the document is not saved. I use the command @Command([FileSave]). – Robert Moszczynski Apr 20 '16 at 12:55
  • Document might got saved but you probably don't see it yet in embedded view. Can you see it when you press F9 in Person document after saving and closing new document? – Knut Herrmann Apr 20 '16 at 12:59
  • Ok, you have right. The documents are saved but I cannot display them. This is an another problem. Thank you! – Robert Moszczynski Apr 20 '16 at 13:03
1

If you want the action in the embedded view, you can do this:

Create the action in the embedded view. Use formula to run an agent

@Command([RunAgent]; "(CreateNotes)")

The agent should look like this:

Dim personDoc As NotesDocument
Set personDoc = workspace.Currentdocument.Document

Dim notesDoc As New NotesDocument(app.CurrentDatabase)

Call notesDoc.Replaceitemvalue("Form", "Notes")
Call notesDoc.Replaceitemvalue("Person_ID", personDoc.ID(0))

Call workspace.Editdocument(True, notesDoc)
Casper Skovgaard
  • 426
  • 4
  • 13
  • It works too and is perhaps a bit cleaner way to do it. Even better is to use the code directly in the view action whitch works too without an agent! The advantage of the solution from @Knut_Herrmann is that there can be dedicated actions for every form. I use the Notes generic and so I can handle it different to the need. I will use your example in many another actions. Thank you! – Robert Moszczynski Apr 20 '16 at 20:20