Document Meta Data

Sep 12, 2013 at 8:58 PM
I have a problem when I choose Document Meta Data.

If I chose only Created From File System, Created is good and Modified corresponds to Upload time which is fine.

If I chose only Modified From File System, Modified is good and Created corresponds to Upload time which is fine.

If I choose both Created and Modified From File System it will only properly keep Modified Date from File SYstem but not Created. Do you have any work around?

Thanks
Coordinator
Sep 17, 2013 at 1:20 PM
Hi,

Thanks for the post.

Can you give some details about you configuration.

This is not something seen before so it would be nice to get some further details and then this can be tested / fixed in the next version. From experience this should work but clearly not for you.

Thanks
Sep 17, 2013 at 1:29 PM
Hi,

I did little debugging on my end and made the following modifications under ImportDocuments.cs

I had to move listitem.Update(); inside if, so when we choose both Created and Modified we call it each time.

So far it works on my end. Thanks for your big effort to develop this.

Thanks, Milos



Before:
    private void AddMetaData(ClientContext context, DataRow datarow, String strDestination)
    {
        // Get a list item for the file we just added
        Microsoft.SharePoint.Client.File file  = context.Web.GetFileByServerRelativeUrl(strDestination);
        file.CheckOut();
        ListItem listitem = file.ListItemAllFields;
        context.Load(listitem);

        // Iterate the mappings in the import settings and apply
        foreach (ImportMapping importmapping in importsettings.ImportMappings)
        {
            try
            {
                // If the import mapping does not require any formatting then just apply directly.
                if (importmapping.FormatType == ImportMapping.FormatTypes.None)
                {
                    listitem[importmapping.InternalName] = datarow[importmapping.DataColumn];
                }
            }
            catch
            {
               // Do nothing, just keep trying any other mappings
            }
        }

        listitem.Update();
        file.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
        context.ExecuteQuery();
    }

After:
    private void AddMetaData(ClientContext context, DataRow datarow, String strDestination)
    {
        // Get a list item for the file we just added
        Microsoft.SharePoint.Client.File file  = context.Web.GetFileByServerRelativeUrl(strDestination);
        file.CheckOut();
        ListItem listitem = file.ListItemAllFields;
        context.Load(listitem);

        // Iterate the mappings in the import settings and apply
        foreach (ImportMapping importmapping in importsettings.ImportMappings)
        {
            try
            {
                // If the import mapping does not require any formatting then just apply directly.
                if (importmapping.FormatType == ImportMapping.FormatTypes.None)
                {
                    listitem[importmapping.InternalName] = datarow[importmapping.DataColumn];
                    listitem.Update();
                }
            }
            catch
            {
               // Do nothing, just keep trying any other mappings
            }
        }

        file.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
        context.ExecuteQuery();
    }
Coordinator
Sep 17, 2013 at 7:56 PM
Thanks for this.

Will take a better look in the next release.

Glad you are up and running.