2
votes

In Notes I have a form (Order) in which I have button "Create new OrderLine" which creates a new form(Orderline). The Order document has an embedded view on the design which gets orderlines documents. Each orderline document contains a hidden field with the ID of the order document, so that you know which orderline is connected with which order. Same goes for Orderline this has an embeddedview with Prices.

In the Order form I have 2 editable text fields: AdministrationNumber and DebtorNumber.

In the OrderlineForm I only got the debtorNumber

In Prices I have a editable number field called Fee.

So I did this on various ways:

In the postOpen of the form prices I have put this LotusScript code:

If( (Source.FieldGetText( "AdministrationNumber" ) = "1" ) And   (Source.FieldGetText( "DebtorNumber" ) = "2") ) Then
    Call Source.FieldSetText("FeePercentage",  "4.235")
    Call Source.Refresh()
End If

But did not work.

In Default Value of Fee I also tried this formula code:

@If((AdministrationNumber="1") & (DebtorNumber= "2");
    "4,235";
        "0"
)

But also of no use..

Is it possible for an editable field to be set when opening the subform based on conditional statement with data which is in the parent form?

Edit

2 ways to solve:

1.

When clicking "Add new Orderline" Button whic is on the Order form, I will call a function in the scriptlibrary, in this function I get values of debnr and admnr and then do the conditional statement.. If true then set FeePercentage

2.

Added new hidden field on the orderlline called admnr which gets the administratorNr field data when the New Orderline Button is clicked.. The field is set through a function in the scriptlibrary.

Eventually in the postOpen of the prices subform this works:

Dim doc As NotesDocument
Set doc = Source.Document
If doc.admnra(0) = "1" And doc.debnr(0) = "2" Then
    doc.FeePercentage = 4.235
End If
2

2 Answers

2
votes

Work with back-end classes instead:

Dim doc as NotesDocument
Set doc = Source.Document
If doc.AdministrationNumber(0) = "1" And doc.DebtorNumber(0) = "2" Then
    doc.FeePercentage = 4.235
End If

It gives you easy access to all fields in document.

2
votes

You say "subform" which has a special meaning in Notes design but it sounds like what you have is a form called "Order", a form called "OrderLine" and a subform called "Prices" that the OrderLine form uses?

In which case, make sure the OrderLine's the "Formulas inherit values from selected document" form property is checked.

That and your default formula should do it if the button is on the parent form (as opposed to view the Order form embeds).

P.S. You might want to change your default formula to

@If(
  (AdministrationNumber="1") & (DebtorNumber= "2"); 4235;
  0
)

so that it returns a number instead of text that looks like a number.