More information on using the workflow actions can be found on my blog for now. I'll probably port the content to here later.

http://blog.petergerritsen.nl/2010/01/13/codeplex-project-for-word-automation-services/

http://blog.petergerritsen.nl/2010/02/18/2-new-worflow-activities-added-to-sp2010-word-automation/

Last edited Feb 27, 2010 at 7:51 AM by peterge, version 3

Comments

hdesmedt Feb 24, 2012 at 2:44 PM 
I confirm this code to copy the fields is working very well, also for meta data properties. Thanks a lot!

gdelgiovine Jun 25, 2010 at 1:56 PM 
You can add the Properties Synchronization adding this code to the common.cs module

----- CODE TO ADD IN COMMON.CS BEGIN HERE -------------------

// <summary>
/// determines if field should be copied
/// </summary>
/// <param name="field"></param>
/// <returns></returns>
internal static bool FieldShouldBeCopied(SPField field)
{
if (!field.ReadOnlyField)
{
if (((field.Type != SPFieldType.Invalid) && (field.Type != SPFieldType.Attachments) &&
(field.Type != SPFieldType.File)) && (field.Type != SPFieldType.Computed))
{
return (!(field.InternalName == "_HasCopyDestinations") &&
((field.InternalName != "_CopySource") && !(field.InternalName == "ContentTypeId")));
}
}
else
{
return false;
}
return false;
}



/// <summary>
/// makes sure that the field can be copied
/// </summary>
/// <param name="fromField"></param>
/// <param name="toField"></param>
/// <returns></returns>
public static bool FieldShouldBeCopiedTo(SPField fromField, SPField toField)
{
if (fromField.Type == toField.Type)
{
if (fromField.Type != SPFieldType.Lookup)
{
if (fromField.Type == SPFieldType.User)
{
SPFieldUser user = fromField as SPFieldUser;
SPFieldUser user2 = toField as SPFieldUser;

if (user.AllowMultipleValues && !user2.AllowMultipleValues)
return false;

if ((user2.SelectionMode == SPFieldUserSelectionMode.PeopleOnly) &&
(user.SelectionMode == SPFieldUserSelectionMode.PeopleAndGroups))
{
return false;
}
}
return true;
}
SPFieldLookup lookup = fromField as SPFieldLookup;
SPFieldLookup lookup2 = toField as SPFieldLookup;

if (!(lookup.LookupWebId == lookup2.LookupWebId))
{
return false;
}
return (lookup.LookupList == lookup2.LookupList);
}
return false;
}

/// <summary>
/// copies list properties excluding readonly fields and fields that are not present in destination list
/// </summary>
/// <param name="source"></param>
/// <param name="destination"></param>
internal static void CopyFieldValues(Microsoft.SharePoint.SPListItem source, Microsoft.SharePoint.SPListItem destination)
{
foreach (SPField sourceField in source.Fields) // loop thru source item fields
{
if (FieldShouldBeCopied(sourceField)) //can we copy this field?
{
if (destination.Fields.ContainsField(sourceField.Title))
// does a field with same title exists in dest list
{
SPField destField = destination.Fields[sourceField.Title];

if (FieldShouldBeCopied(destField) && FieldShouldBeCopiedTo(sourceField, destField))
// do the field types match?
{
//user lookup ids are not valid when copying items cross site, so we need to create new lookup ids in destination site by calling SPWeb.EnsureUser()
if (sourceField.Type == SPFieldType.User && source[sourceField.Title] != null &&
source.ParentList.ParentWeb.ID != destination.ParentList.ParentWeb.ID)
{
try
{
SPFieldUser fieldUser = sourceField as SPFieldUser;

if (fieldUser != null && fieldUser.AllowMultipleValues == false)
{
SPFieldUserValue userValue = new SPFieldUserValue(source.ParentList.ParentWeb,
source[sourceField.Title].
ToString());

destination[sourceField.Title] =
destination.ParentList.ParentWeb.EnsureUser(userValue.User.LoginName);
}
else
{
SPFieldUserValueCollection useValCol =
new SPFieldUserValueCollection(source.ParentList.ParentWeb,
source[sourceField.Title].ToString());

SPFieldUserValueCollection destValCol = new SPFieldUserValueCollection();

foreach (SPFieldUserValue usr in useValCol)
{
SPUser destUser =
destination.ParentList.ParentWeb.EnsureUser(usr.User.LoginName);

destValCol.Add(new SPFieldUserValue(destination.ParentList.ParentWeb,
destUser.ID, string.Empty));
}

destination[sourceField.Title] = destValCol;
}
}
catch
{
}
}
else
destination[sourceField.Title] = source[sourceField.Title];
}
}
}
}
}

----- END OF CODE TO ADD TO COMMON.CS ----------------------

Into the Copy Document Activity code you can add this

---------------- CODE TO ADD INTO CUSTOM ACTIVITY CODE ----------

// after the job submission you can insert a loop to get the conversion job status
// PLEASE NOTE : this is a viable solution ONLY if you set a very short time range for the Word Conversion Service (1 minute...)

do
{

System.Threading.Thread.Sleep(2000);
status = new ConversionJobStatus(wordServiceApplicationProxy, JobGUID, null);


if (status.Count == status.Succeeded)
{
ConversionJobStatus = "Completed";

ConvertedFileName = CurrentFileName;


SPListItem SourceSPListItem=SourceSPWeb .GetListItem(__Context.CurrentItemUrl);
SPListItem DestSPListItem = DestinationWeb.GetListItem(OutputFileUrl);
Common.CopyFieldValues(SourceSPListItem, DestSPListItem);
DestSPListItem.SystemUpdate();


break;
}
else if (status.Count == status.Failed)
{
ConversionJobStatus = "Failed";
break;
}
else if (status.NotStarted > 0 || status.InProgress > 0)
{

}


} while (true);