@Contains (Formula Language)

Determines whether a substring is stored within a string.

Syntax

@Contains( string ; substring )

Parameters

string

Text or text list. The string(s) you want to search.

substring

Text or text list. The string(s) you want to search for in string.

Return value

flag

Boolean.

Usage

This function is case-sensitive.

If either parameter is a list, the function returns 1 if any element of parameter 1 contains any element of parameter 2.

You cannot use this function to test for substrings in a rich text field.

Avoid using this function to test for an exact match (that is, parameter 2 equals parameter 1). The result will be wrong if parameter 1 is not an exact match but does contain parameter 2. Use the equal operator or @IsMember, which will give the desired result and are more efficient.

Examples

  1. This example returns 1 to indicate that the substring, "Th," is contained in the string, "Hi There."
    @Contains("Hi There";"Th")
  2. This example returns 1 to indicate that the items in one text list are contained in the other text list.
    @Contains("Tom":"Dick":"Harry";"Harry":"Tom")
  3. This example returns 1 to indicate that the single text item in one parameter is present in the text list that makes up the other parameter.
    @Contains("Tom";"Tom":"Dick":"Harry")
  4. This input validation formula for the "RequestShipDate" field checks if the date in the field is invalid or if the field named ProductLeadTime contains the phrases "weeks" or "month." If either condition is true, when the user saves the document a message box displays stating, "You must request a valid ship date."
    @If(@Contains(ProductLeadTime;"weeks":"month"); @If(!@IsTime(RequestedShipDate);
    @Failure("You must request a valid ship date.");@Success;@Success)
  5. This view selection formula creates a new view that includes only documents that have a Subject field containing the text "Mary Lamb" (in any case).
    SELECT form = "Memo" & @Contains(@LowerCase(Subject); "mary lamb")
  6. This action formula opens a WebForm instead of a NotesForm if the user executing the action is assigned the role of "[WebUser]" in the ACL.
    @Command([Compose]; @If(@Contains(@UserRoles; "WebUser"); "WebForm"; "NotesForm"))
    Note: For this example to work, the Enforce a consistent ACL across all replicas of this database option must be selected.

Language cross-reference

InStr function in the LotusScript® language


Additional Documentation | Trademarks |