1

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 )

Phaul Guen
  • 15
  • 2
  • 6
  • Seems you want to make selection formula in that view, which will return true for documents meeting your condition. It is quite simple by using For or Transform in combination with GetField, but I think your view might become a performance issue. – Frantisek Kossuth Feb 25 '13 at 09:23
  • You also should not use the prefix txt_ for numeric fields... Most programmers would assume that those fields are in fact text fields. As a new Notes developer, you might benefit from reading this article: http://blog.texasswede.com/how-to-write-better-code-in-notesdomino/ Especially the first article. I am just curious, what is your previous development/programming experience? What languages/platforms? – Karl-Henry Martinsson Feb 28 '13 at 23:30

2 Answers2

2
  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
Dmytro Pastovenskyi
  • 5,240
  • 5
  • 37
  • 56
  • I want to add that code in the view column. So, let say if the condition is OK => i want to print a field name called txt_side, if not OK => "" – Phaul Guen Feb 25 '13 at 11:58
  • then replace last line of code (_res) to @if(_res=1; txt_side; ""), hope txt_side is a field with some text, but I guess you are doing something in wrong way. but nvm, the code I've added should solve ur problem – Dmytro Pastovenskyi Feb 25 '13 at 12:01
  • Thanks, dear dmytro.... but, now when I run the view i get 'NotCategorized' ... and the field txt_side has text.... The column is sorted ascending and categorized. – Phaul Guen Feb 25 '13 at 12:06
  • I'd recommend you to read a bit more about views in LN, you are doing something wrong. – Dmytro Pastovenskyi Feb 25 '13 at 12:17
  • Dmyto's suggestion that you compute the value on the document is FAR better than having it part of a column formula. If the formula is on the document, it only has to be computed when the document is saved, while if it's in the view, it has to be computed every time you open the view. – David Navarre Feb 25 '13 at 17:32
0

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.

Karl-Henry Martinsson
  • 2,770
  • 15
  • 25