Phaul Guen
Phaul Guen

Reputation: 15

Lotus Notes - multiple IF formula statements

I'm new in Lotus Notes programming and I need your advices and your help.

My main form contains a table with 8 rows and 2 columns. ( there are 16 cells ) Every each cell has a numeric field. My fields name are :

txt_n1 and txt_i1 ( for 1st row )

txt_n2 and txt_i2 ( for 2nd row )

....

txt_n8 and txt_i8 ( for 8th row )

What I want to do is:

I have a view called vwMarketing with just one column. I want this view to display only those docs. in which there is at least one or more rows which its cells contains equal values.

So, if let say txt_n4 = txt_i4 => OK

row(k) (where k=1..8) : if cell 1 value is 5 and cell 2 value is 5 => OK.

There could be more than one row with this property, important is to exist at least one, and the values not to be null. I hoped i was pretty clear, thanks !

PS: Actually, the formula statement i want to be in the column, so if it is OK => "A" and if not => "" ( in the view property, I checked : Don't show empty categories )

Upvotes: 1

Views: 3844

Answers (2)

Karl-Henry Martinsson
Karl-Henry Martinsson

Reputation: 2795

I would solve it slightly different:

  1. Create a hidden text field on your form called 'DisplayInView' (or similar).
  2. Modify the view selection: SELECT DisplayInView="Yes"
  3. Add the code below to the PostSave event of your form:

    Dim thisdoc As NotesDocument
    Dim isSame As Boolean
    isSame = False
    Set thisdoc = source.Document
    '*** Loop through all fields in document and compare the field pairs
    Forall i In thisdoc.Items
        If Left(i.Name,5) = "txt_n" Then
            If i.Text = thisdoc.GetItemValue( Replace(i.Name,"txt_n","txt_i") )(0) Then
                isSame = True
                Exit Forall
            End If
        End If
    End Forall
    If isSame Then
        Call doc.ReplaceItemValue("DisplayInView","Yes")
        Call doc.Save(True,False)
    End If
    

I haven't tested it, but I believe it should work.

Upvotes: 0

Dmytro Pastovenskyi
Dmytro Pastovenskyi

Reputation: 5419

  1. if you have small amount of documents in the view, then as u were suggested use Selection Formula to exclude documents with wrong condition.
  2. you can add computed item/flag into your documents, field will compute if the document should be displayed in the view or not. then you will not have performance issue. i.e.

but code you need should look like that (that will check if documents is fine to be displayed in view or not), if you use it in view - just put after all Select _res = 1 otherwise if you decide to use flag into document (to increase performance) then Select youritem = 1

   _res := 0;
    @For(i:=1;i<=8;i:=i+1;
        _post := @Text(i);
        _txt_n := @GetField("txt_n"+_post);
        _txt_i := @Text(@GetField("txt_i"+_post));
        @If(    (_txt_n=_txt_i) & (_txt_n!=""); 
                @Do(    _res := 1; i:=9);
                0
        )
    );
    _res

Upvotes: 2

Related Questions