Programmatically calculate linkedDocument