Naming Citations in Preparation for RM8 #RM7 #Citations

In RM8, citations are re-useable and have a name which is made by concatenating the contents of the citation fields.
So I run this script on my RM version 7 database so that it is ready for importing into RM version 8.

I have taken advantage of this concatenation to get meaningful names by inserting a new field in my own templates as the first one in a citation and then setting the value in the citations to the source name.

This will only work for user templates, not for supplied ones (SourceTable.TemplateID > 10000)

/* update citations for RM8
 add in new field - CitItemD for citation name and put in source name - creates good citation name in RM8
*/
UPDATE SourceTemplateTable
SET (FieldDefs) = cast(Replace(cast(FieldDefs as Text),'<Root><Fields>','<Root><Fields><Field><FieldName>CitItemD</FieldName><DisplayName>Item Name</DisplayName><Type>Text</Type><Hint>Item Name</Hint><LongHint>To distinguish citations</LongHint><CitationField>True</CitationField></Field>') as blob)
WHERE 
TemplateID > 10000;

-- or this could be TemplateID = a specific template number to just change one template

-- add extra field for name - at the start so it is used for citation name when converting to v8
UPDATE CitationTable 
SET (Fields) = (SELECT cast(Replace(cast(CitationTable.Fields as Text),'<Root><Fields>','<Root><Fields><Field><Name>CitItemD</Name><Value>' || SourceTable.Name ||  '</Value></Field>') as blob) 
                                FROM  SourceTable 
                                WHERE SourceTable.SourceID = CitationTable.SourceID )
WHERE
    EXISTS (
       SELECT *
       FROM SourceTable 
        WHERE (SourceTable.SourceID = CitationTable.SourceID) 
AND SourceTable.TemplateID > 10000
-- or this could be TemplateID = a specific template number, to just change one template
   );

3 Replies to “Naming Citations in Preparation for RM8 #RM7 #Citations

  1. There is or was a problem in RM7.9.320 that I have not checked for in 350 that created false merges from the new Merge Duplicate Citations function because it considered only the fields in the CitationTable, not links from potentially differing WebHints and Media. Many citations imported through TreeShare have all those fields empty and therefore equal despite having different media. Your script could preclude such false duplications because one of the fields tested by the Merge is the Citation Name. By putting the person name or other unique information into the Source name and with your script populating Citation Name with it, the merge would be precluded.

    However, I don’t think the Source Name from TreeShare is differentiated across many different citations so false merging could still be a problem. I posted this risk to feedback. The proper fix is for RM to test for differences in WebHints and Media along with the text fields of the Citation.

  2. I have been playing with the query. I have made three changes.

    I removed the parentheses from SET, viz. SET (FieldDefs) = is changed to SET FieldDefs = The version of SQLite I am using will not accept the parentheses.

    I changed TemplateID > 10000 to TemplateID >= 10000. Otherwise, my first user defined template was omitted from the query.

    I changed the string Item Name to Initial Citation Name for reasons of purely personal preference.

    So far, it all seems to work extremely well.

  3. I also broke it into two separate queries, one for the SourceTemplateTable and one for the CitationTable. It runs fine as written, but by running it as two separate files I can see the update counts for each table.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.