Is it possible to update the modifiedby and LastModified date properties using the API?

Hello I am currently creating a standalone C# application that is using the COM API to create an object in M-Files and I would like to be able to set the modified date and modified by but I have tried every method I can think of and it still does not set the property. I am able to set all properties successfully except the modified by and last modified. I was wondering if this is even possible and if so what method should I be using. Here are the different options that I tried 

1.) Creating the propertyValue and adding it to the propertyValues object and passing it in with all the other properties during object creation. 

PropertyValue modByProp= new PropertyValue()
modByProp.PropertyDef = 23
modByProp.TypedValue.SetValue(MFDataType.MFDatatypeLookup, propertyInfo.itemID);
propvals.Add(-1, modByProp);
vault.ObjectOperations.CreateNewObjectEx(objectTypeID, propvals, sourceFiles, isSingle, true, null);

2.) Creating the object and updating it using SetLastModificationInfoAdmin

ObjectVersionAndProperties ovp = vault.ObjectOperations.CreateNewObjectEx(objectTypeID, propertyValues, sourceFiles, isSingle, false, null);
vault.ObjectPropertyOperations.SetLastModificationInfoAdmin(ovp.VersionData.ObjVer, UpdateLastModifiedBy: true, modByPropval.Value, UpdateLastModified: true, modifiedPropval.Value);
vault.ObjectOperations.CheckIn(ovp.ObjVer);

3.) using the setProperty finction instead of SetLastModificationInfoAdmin

ObjectVersionAndProperties ovp = vault.ObjectOperations.CreateNewObjectEx(objectTypeID, propertyValues, sourceFiles, isSingle, false, null);
vault.ObjectPropertyOperations.SetProperty(ovp.VersionData.ObjVer, modByPropval);
vault.ObjectOperations.CheckIn(ovp.ObjVer);

Any Help would be very much appreciated. 

  • I just tried this using a local C# application and it seemed to work:

    var properties = new PropertyValues();
    {
        var classProperty = new PropertyValue();
        classProperty.PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass;
        classProperty.Value.SetValue(MFDataType.MFDatatypeLookup, (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassUnclassifiedDocument);
        properties.Add(0, classProperty);
    }
    {
        var nameProperty = new PropertyValue();
        nameProperty.PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefNameOrTitle;
        nameProperty.Value.SetValue(MFDataType.MFDatatypeText, "hello world");
        properties.Add(0, nameProperty);
    }
    var obj = vault.ObjectOperations.CreateNewObjectEx(0, properties, CheckIn: false);
    {
        var lastModifiedBy = new TypedValue();
        lastModifiedBy.SetValue(MFDataType.MFDatatypeLookup, 35);
        var lastModifiedDate = new TypedValue();
        lastModifiedDate.SetValue(MFDataType.MFDatatypeTimestamp, new DateTime(2000, 1, 1, 0, 0, 0));
        vault.ObjectPropertyOperations.SetLastModificationInfoAdmin
        (
            obj.ObjVer, 
            true, lastModifiedBy, 
            true, lastModifiedDate
        );
    }
    vault.ObjectOperations.CheckIn(obj.ObjVer);

    (in the above I was connected as Craig Hawker, but I set the last modified by to "test", and set the last modified by datetime to 2000-01-01)