I have a document library with a .dotx template associated. Some of the fields are interconnected with each other. For instance, when a user chooses employee John through the DIP, the other field must be automatically filled with John's Phone. Not only fields in DIP should be updated this way, but fields in the template body too.
Some of the connections are even more complicated, like "take John's department, find its director, and output his office number", so I think I can handle this only in server code through the event receiver. That's how I do it:
public override void ItemUpdated(SPItemEventProperties properties)
{
base.ItemUpdated(properties);
base.EventFiringEnabled = false;
SPListItem item = properties.ListItem;
item["RoomNumber"] = //take John's department, find its director, and output his office number;
item.SystemUpdate(false);
base.EventFiringEnabled = true;
}
But even then fields are updated only on server side but not in the Word template on the user's machine. User has to save, then close and re-open the document if he wants to see updated fields.
Is there any way I can update fields in opened document through a server side code? Is there any other solution to this problem?