Hi, I am trying to write a loan stock system. When the main loan header form has been saved the user gets the option to create some loan items.
There is an embedded view with an Add Item button which runs this agent.
Option Public
Option Declare
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim db As NotesDatabase
Dim headerdoc As NotesDocument, itemdoc As NotesDocument
Dim retflg As Boolean
Set db = s.CurrentDatabase
Set headerdoc = ws.CurrentDocument.Document
Set itemdoc = db.CreateDocument
itemdoc.LoanNumber = headerdoc.LoanNumber
temdoc.LoanCustomer = headerdoc.LoanCustomer
itemdoc.LoanStatus = headerdoc.LoanStatus
itemdoc.ValidSN ="No"
itemdoc.Form = "ITEM"
retflg = ws.DialogBox("Loan Stock Item", True, True, True, False, False, False, "Add New Item", itemdoc, True, True)
Call itemdoc.MakeResponse(headerdoc)
End Sub
It doesn’t seem like I am creating a response document properly. If I use a view selection containing @alldescendants the items don’t show and if I use @SetDocField($Ref; “ResponseFlag”; “Yes”); on the save button in the item form it doesn’t write the value back to the parent.
I am not great on passing values back and forth between parent and child and vice versa so any good advice gratefully received.
Thanks.
Subject: pls save me
You haven’t saved the response document…
A couple of things that might help…
- Always create a Designers view of all documents. Set the first column (categorised) to display the form/stored form:
@If($Title=“”;Form;$Title)
Display @Created/@Modified in the second column .
This will let you see what documents are being created (or not in your case) with what form name.
-
Don’t use response documents unless you are reinventing the discussion database. Displaying responses in a view is restrictive and accessing $Ref awkward so roll your own ‘foreign key’ - copy the UNID of the parent into child documents (ParentDocId).
-
Don’t use Notes for relational data… unless the PHB insists. Front-ending a relational store is alright but as it used to say on page 1 of the developers guide - Notes is not suited to relational, order/invoice etc type apps.
-
If you need to store detail lines have a look in the Sandbox for TableWalker. It’s a configurable component you can use to maintain lines of data in several multi-value fields.
HTH,
Gerry
Subject: RE: pls save me
Gerry,
Thanks for coming back to me so fast. This looks really helpful advice and I will have a play with it this afternoon.
Ironically I did have Call itemdoc.Save(True, False) in the agent at the start, but then when a user clicked cancel it was leaving an empty record in the database which would then need to be taken back off.
I have used Tablewalker before as well as it holds our training records in our staff database so I will revisit this angle as well.
Thanks again.