This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

search for class document objects per project comapi c#

I'm trying to write a report of document objects by class per project using the comapi in C#. I've wrote a search condition that iterates through each object class looking for the property definition id for the project but I'm not getting the results I'm expecting. I need some guidance as to what I'm doing wrong


ObjTypes oObjectTypes = mfServerApplication.LogInToVault(GetVaultGuid).ObjectTypeOperations.GetObjectTypes();
foreach (ObjType oObjType in oObjectTypes)
{
//foreach (PropertyDef propDef in propDefs)
//{
int propertydef = 0;
var searchConditions = new SearchConditions();

// Add an object type filter.
{
// Create the condition.
var condition = new SearchCondition();

// Set the expression.
condition.Expression.SetStatusValueExpression(MFStatusType.MFStatusTypeObjectTypeID);

// Set the condition.
condition.ConditionType = MFConditionType.MFConditionTypeEqual;

// Set the value.
condition.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeLookup,
oObjType.ID);

// Add the condition to the collection.
searchConditions.Add(-1, condition);
}

// Add a "not deleted" filter.
{
// Create the condition.
var condition = new SearchCondition();

// Set the expression.
condition.Expression.SetStatusValueExpression(MFStatusType.MFStatusTypeDeleted);

// Set the condition.
condition.ConditionType = MFConditionType.MFConditionTypeEqual;

// Set the value.
condition.TypedValue.SetValue(MFilesAPI.MFDataType.MFDatatypeBoolean, false);

// Add the condition to the collection.
searchConditions.Add(-1, condition);
}


{
// Create the condition.
var condition = new SearchCondition();


//condition.Expression.SetPropertyValueExpression(propDef.ID, MFParentChildBehavior.MFParentChildBehaviorNone);
condition.Expression.SetPropertyValueExpression(propertydef, MFParentChildBehavior.MFParentChildBehaviorNone);

// Set the condition.
condition.ConditionType = MFConditionType.MFConditionTypeEqual;
//1454 is the Arm Project id
condition.TypedValue.SetValue(MFDataType.MFDatatypeMultiSelectLookup, 1454);


var customerObjectTypeIndirectionLevel = new PropertyDefOrObjectType();
customerObjectTypeIndirectionLevel.PropertyDef = false; // We do not care which property definition is used.
customerObjectTypeIndirectionLevel.ID = oObjType.ID; // Instead care which object type it is related to.
condition.Expression.IndirectionLevels.Add(-1, customerObjectTypeIndirectionLevel);

// Add the condition to the collection.
searchConditions.Add(-1, condition);
}

ObjectSearchResults searchRes = mfServerApplication.LogInToVault(GetVaultGuid).ObjectSearchOperations.SearchForObjectsByConditionsEx(searchConditions,
MFSearchFlags.MFSearchFlagNone, SortResults: false);

foreach (var results in searchRes)
{

Console.WriteLine(results);

}
}