setting a search condition on a lookup property but with text


i would like to set a search condition on a lookup property but i have to search for a text value within:

so i would like to use

SearchCondition sc = new SearchCondition();
sc.ConditionType= MFConditionType.MFConditionTypeStartsWith;

how can i do this on a lookup value?

for example:

in a multi lookup there are several selected values for my search criteria


2)  2.3

3)  1.1.4

now i have to find all objects, that have selected values in their lookups, but there can also be values such as:

1)     -> this one starts with the first search criteria so it should be in the result collection

2)         -> this one starts with the second criteria 2.3 so it should be in the result collection


so i have to find all objects that have values in a lookup that start with and 2.3 and so on. - from the search criteria

how can this be done?

thank you

  • No idea if this is the best way to do it, but this is how I do it.  I will use the following code to get a value list item ID (you could tweak the Where method to return any number of ).

    int[] invoiceOriginId = vault.ValueListItemOperations
        .GetValueListItems(vault.ValueListOperations.GetValueListIDByAlias("My Alias"))
        .Where(i => i.Name == "SO")
        .Select(i => i.ID);

    Then once you have all the IDs in an array, you can use the "one of" search defined here:

  • hi

    i don't think this would work. 

    my search conditions are some lookup values (looking on an object, not value list) chosen on some metadata card.

    for example

    searchconditions - "2.1" - that is the text value you can see on the metadata card, but is a lookup value

                                - "1.4.3"  -||-

                                -  "3"

    and so on

    my search result should return objects, that have lookup values  -  because it starts with 2.1

    2.1.5   -  because it starts with 2.1    - because it starts with 1.4.3

    1.4.3   - because it starts with 1.4.3

    3.2.1   - because it starts with 3


    getting all IDs possible so i can search for objects is not what i want to do.

    that would mean i have to get all IDs, that are on the same level or under.

    for example

    if i have 2.1 i would have to get all underlying IDs (it goes 4 levels deep) and the do the search for each one












    doing a "startswith" would be perfect. But this works on a text PD.

    thank you

  • Have done stuff like this using a traditional search operation with 2 conditions, one to define the object type and one that use "Contains" on the object name. "StartsWith" might be better suited here.

    In your case you need to run the search once for each of your selected values and add the search results to a common list. When done that list contains all of the desired objects.

  • Hi

    Thank you for the reply.

    I don't see how this would work. If i do a search for each lookup value in my search condition, i would only get results that have exactly those values in lookups.

    But i also need to check for all other lookup values, that are not among the search conditions.

    Like i described before:

    i have let's say 4 lookup values for my search conditions.

    I have to find all objects that have those lookup values or lookups that are on the next lower level.

    if my search condition is "2.3" - (a lookup value)

    then my search result should return objects that have lookup values such as




    the one "2.3" that is selected on my search condition card, is not necessarily also on the objects card.

    thank you

  • You can search for value list items with the "starts with" condition type: Searching for value list items (

    Once you have those items, you can doa "one of" search: Search conditions in the M-Files API

  • Hi Craig

      and you Craig are telling the same thing, so i had to re-think your logic.

    I should first have to find all the search conditions from those 3 that i have set as my original search conditions, and then all objects that are connected to those lookup values.

    At first i didn't get the logic behind that, because i was starting my search logic from the other end.

    I wanted to search for all the objects without getting all search IDs, just "starts with", so i apologize to DCPDamon. You are both right.

    i would like to accept the answer from DCPDamon, but at the same time yours, since they are telling me the same logic Slight smile

    Can i accept both?

    thank you

  • Simply click the accept button next to both. A question can have two accepted answers.