How to search unmanaged object by using Property ?

I want to search and collect some unmanaged objects based on their names and promote them into managed objects, I have tried many things but no luck.

Could someone please help on this ?

My search logic is like below

SearchConditions searchCondtions = new SearchConditions();
SearchCondition searchCondtion = new SearchCondition();
searchCondtion.ConditionType = MFConditionType.MFConditionTypeEqual;
searchCondtion.Expression.SetStatusValueExpression(MFStatusType.MFStatusTypeObjectTypeID, null);
searchCondtion.TypedValue.SetValue(MFDataType.MFDatatypeLookup, 0);

searchCondtion = new SearchCondition();
searchCondtion.ConditionType = MFConditionType.MFConditionTypeEqual;
searchCondtion.Expression.SetPropertyValueExpression(0, MFParentChildBehavior.MFParentChildBehaviorNone );
searchCondtion.TypedValue.SetValue(MFDataType.MFDatatypeText, "FileName");
searchCondtions.Add(1, searchCondtion);

var result = Vault.ObjectSearchOperations
.SearchForObjectsByConditions(searchCondtions, MFSearchFlags.MFSearchFlagIncludeUnmanagedObjects, true)
.Cast<ObjectVersion>()
.FirstOrDefault();

Parents Reply Children
  • If you're talking about search then you would run the search against the full text index (e.g. Search conditions in the M-Files API), then use the ObjVer returned in the search results.

    If you're talking about manually creating an ObjVer to promote it, then the ObjVer class has properties for the external repository name and external repository object ID which you would need to populate.

  • Where should we run this code ? I run the below code in a separate test application where I connected and authenitcated the vault using API by supplying credentials

    var searchConditions = new SearchConditions();
    {
    var condition = new SearchCondition();
    condition.Expression.SetPropertyValueExpression((int)MFBuiltInPropertyDef.MFBuiltInPropertyDefRepository, MFParentChildBehavior.MFParentChildBehaviorNone);
    condition.ConditionType = MFConditionType.MFConditionTypeEqual;
    var lookup = new Lookup();
    lookup.ExternalRepositoryName = "90bb252efa09494b8662332ba5d49d77"; // The connection ID, shown in the configuration.
    condition.TypedValue.SetValue(MFDataType.MFDatatypeLookup, lookup);
    searchConditions.Add(-1, condition);
    }
    
    
    var results = Vault.ObjectSearchOperations.SearchForObjectsByConditionsEx(searchConditions, MFSearchFlags.MFSearchFlagIncludeUnmanagedObjects, false, MaxResultCount: 0, SearchTimeoutInSeconds: 0).Cast<ObjectVersion>();
    foreach (var item in results)
    {
    if (string.IsNullOrWhiteSpace(item.ObjVer.ObjID.ExternalRepositoryName))
    continue;
    Console.WriteLine($"{item.Title} ({item.ObjVer.ObjID.ExternalRepositoryName})");
    }

  • How do you connect to the vault?  My guess is that you're not specifying that you support unmanaged objects.  The default is to exclude unmanaged objects as they operate differently to standard objects, and API code needs to be careful not to make assumptions.

    To specify that you support unmanaged objects you need to correctly set the client capabilities inside the connection data when you connect.  This requires you to use one of the connect methods that supports this, e.g. M-Files API - ConnectEx7 Method

  • it works now but still I am unable to filter the objects based on the Name or Title property. Is this also expected?

  • Unmanaged objects are available in the full-text search index, but they aren't objects in the vault database and so don't have properties that you can query.

    Unmanaged objects do not have properties.  They are only available in the full-text search index.

  • Hi, The below condition works fine but

    var condition = new SearchCondition();
    condition.Expression.SetPropertyValueExpression((int)MFBuiltInPropertyDef.MFBuiltInPropertyDefRepository, MFParentChildBehavior.MFParentChildBehaviorNone);
    condition.ConditionType = MFConditionType.MFConditionTypeEqual;
    var lookup = new Lookup();
    lookup.ExternalRepositoryName = "90bb252efa09494b8662332ba5d49d77"; // The connection ID, shown in the configuration.
    condition.TypedValue.SetValue(MFDataType.MFDatatypeLookup, lookup);
    searchConditions.Add(-1, condition);

    Similiarly I need to add a condtion with MFBuiltInPropertyDefCreatedFromExternalLocation ( could not find out what the value and where to get to supply here)

    Please see the image below I need to find this document based on the location or IML FIle Path and then I need to promote it 

    Could you please suggest an approach ?

    Thank you very much for your answers