When a TreeShare linked Ancestry Source is Memorised and Pasted through RootsMagic Citation Manager, the pasted source loses its TreeShare link. The TreeShare update to the Ancestry Tree creates a new Other Source rather than linking to the Ancestry Source. This script creates a TreeShare link for such pasted Ancestry Sources from that of the original linked Ancestry Source.
The script has had little testing. Possibly there are types of Ancestry Sources whose extID in RM is NOT independent of the person or event, the principal on which the script was designed. Undesired outcomes might result.
Safest approach is to close out of TreeShare, run the script and reopen TreeShare to work through the updates to the Ancestry Tree.
For a newly downloaded Tree in which editing is just beginning, it is possible to run the script while in the Edit Person screen launched from TreeShare or even in the TreeShare Compare screen. I cannot say yet whether either is any less safe than closing and reopening TreeShare to carry out the updates. It is certainly more convenient and faster.
TreeShare-LinkPastedAncestrySources Rev 2018-01-27 excludes OtherSources
The Memorise-Paste function should be enhanced to memorise the extID of the linked citation along with its CitationID and to paste both the new Citation record and the new LinkAncestryTable record with the original extID. That procedure would not suffer the ambiguity that the above script has to deal with for Other Sources because it cannot know which linked citation was the original where there are multiples.
RM created sources are uploaded by TreeShare to become “Other Sources” on the Ancestry Tree. A link is (unreliably) established between the RM Citation and the Other Source as a record in the LinkAncestryTable. Its extID value appears to be person or even event-dependent. Thus the simple matching of an unlinked SourceID and Fields values from the CitationTable with citations that do have TreeShare links, as used for Ancestry Sources is insufficient for Other Sources.