Manage Learn to apply best practices and optimize your operations.

Setting row colors by category in a Lotus Notes view

Discover how you can set row colors to different categories in a Lotus Notes view, even when the categories are unknown or dynamic, using Formula and LotusScript.

In a Lotus Notes view, you can easily set colors to rows based on category, but only if the categories are known. If the categories are unknown or dynamic, setting the row colors by category gets trickier. Here's how to accomplish it.

  1. Create a Lotus Notes view named 'ColorP.' Add a sorted, categorized column for the value you categorize in the document. In this case, let us say DDHID is the field you want to categorize on. In the last tab of the column properties, type DDHID in Programmatic Use Name. Use the same view selection formula as you would keep for the main view (call it 'Main View') displayed to the user.

  2. Create a profile document and name it "WebLogProfile" form.

    Create the four fields as follows:

    Sender1B (Color type, Editable),
    Sender1F (Color type, Editable),
    Sender2B (Color type, Editable),
    Sender2F (Color type, Editable)
    Create a field named 'List2Field' as computed -- do not make it multi-value.

    Add the following formula:

    database := @Subset(@DbName; -1);
    server := @Name([CN]; @Subset(@DbName; 1)); 
    Sender1List := @Sort(@Unique(@Trim(@DbColumn
    ("";server:database; "ColorP";1))));
    GetSenderList := """ + @Implode
    (Sender1List; "":"") + """; GetSenderList

    Add a second field '$color1' as computed -- do not make it multi-value.

    Add the following formula, don't worry about tmpColorButton, it is a temporary variable:

    @If(tmpColorButton = "1"; "";
    "S_1B :=  "" + Sender1B + "";  S_1F :=  
    "" + Sender1F + "";  
    S_2B :=  "" + Sender2B + "";  S_2F :=  
    "" + Sender2F + "";   colr1 := S_1B 
    :   S_1F ; colr2 := S_2B   :   S_2F ;      
    @If(@Modulo(@Member(DDHID ;  " 
    + List2field + ")
      + 1; 2) = 0 ; colr1;colr2 )")
  3. Create a view named 'Main view,' this will be shown to the user.

    Add the first column as a hidden column, then select "use value as color" and "User Definable." In the Profile Document: "WebLogProfile." In the last tab of column properties under Programmatic Use Name {type}:

    $color1 ( check Hide column)
    In the column formula: @Trim(DDHID)
  4. Edit the "WebLogProfile" document and select colors for Sender1B, Sender1F, Sender2B, Sender2F. Save this and close the document.

  5. You may need to refresh the WebLogProfile document somehow (any way you want in the backend). Here is an example in LotusScript:
    set profiledoc = 
    success = 
    profiledoc.Computewithform(False, False) 
    if success then 
    call profiledoc.Save(TRue, TRue) 
  6. Verify that the alternate color is shown per category. Remember, you may need to close and open the view in order to refresh the color.

Do you have comments on this tip? Let us know.

This tip was submitted to the tip library by member Naveen Gupta. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Dig Deeper on Lotus Notes Domino Formula Language

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...