* Querying Source Citations

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
User avatar
Talln
Gold
Posts: 18
Joined: 09 Feb 2021 17:15
Family Historian: V7
Location: London

Querying Source Citations

Post by Talln » 15 Mar 2022 18:41

Hi, I'm sure this must have been raised before, but if so I can't find the answer in FHUG. Sorry.

I'm trying to extract citation data from FH - initially using a Query, and then when prototyped, in a LUA Plug-In - specifically:
  • Citation-specific details fields
  • Citation Text instances
  • Citation Notes instance
  • Citation Media instances (filename, title, date, etc)
I get that citations can related to various different data items in FH and that it's non-trivial to locate all the citations...but I can't figure out how to extract the data for a single citation, say the citation text for the burial of an individual. I can retrieve the source %INDI.BURI.SOUR>% without problem...but no citation data.

Clearly the data is there in the GEDCOM and in FH, and I can generate a standard FH Report with the data...but how do you get the data out using a FH Query and/or via the LUA API ?

Thanks for your help.

Talln

PS Is there a complete reference list of FH API functions anywhere ... ? I've tried googling some of the basic ones and found nothing...and not found anything in the forum...
Paul Weaver, London

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Querying Source Citations

Post by ColeValleyGirl » 15 Mar 2022 18:47

Talln wrote:
15 Mar 2022 18:41
PS Is there a complete reference list of FH API functions anywhere ... ? I've tried googling some of the basic ones and found nothing...and not found anything in the forum...
The FH API is documented in the How to Write Plugins Help (accessible from the Plugins Window under More, or here: Online FH Plugin Help)

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Querying Source Citations

Post by tatewise » 15 Mar 2022 20:03

When you are editing a plugin script in Lua, the Help button in the toolbar at the top offers many helpful resources including the Family Historian API. However, maybe you are confusing Plugin API Functions, with Expressions used elsewhere that comprise FH Data References and FH Functions. See FHUG Knowledge Base Understanding Expressions.

The data reference %INDI.BURI.SOUR>% that you quoted, ends with a > which is a pointer to another record.
In this case, that other record is the SOUR (i.e. Source) record and not the Citation which is local to the BIRT fact.
So you need %INDI.BURI.SOUR.DATA.TEXT% for the citation Text from Source.
Similarly, %INDI.BURI.SOUR.NOTE2% for the citation Note.
Also, %INDI.BURI.SOUR.OBJE>FILE.TITL% for the citation Media Title, which points to the Media OBJE> record.
It gets more complicated for Citation-specific templated fields where the data reference depends on the type and name.

To discover such data references, open an appropriate Query, which for this case, All Individuals is good.
Then on the Columns tab, use the Fields pane with the box below set to Show Both in Box.
Also, see FHUG Knowledge Base Understanding Data References.

It is far from easy to list all citations in one Query because some are attached to Individual or Family records and others attached to Names and Facts. So you need at least three different types of Query.

Have you tried the Where Used Record Links plugin that lists all Citations for any selected Source records?
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
AdrianBruce
Megastar
Posts: 1962
Joined: 09 Aug 2003 21:02
Family Historian: V7
Location: South Cheshire
Contact:

Re: Querying Source Citations

Post by AdrianBruce » 15 Mar 2022 20:47

tatewise wrote:
15 Mar 2022 20:03
... It is far from easy to list all citations in one Query because some are attached to Individual or Family records and others attached to Names and Facts. ...
Indeed. And isn't it also even more complex because each Individual record / Name / Fact, etc., can have multiple citations for the single Fact, etc. For example, there can be several citations for the (single) burial of an individual.

Could we step back a bit and understand why you want to extract the citation data, in case there are alternative routes to the desired result?
Adrian

User avatar
Talln
Gold
Posts: 18
Joined: 09 Feb 2021 17:15
Family Historian: V7
Location: London

Re: Querying Source Citations

Post by Talln » 16 Mar 2022 14:03

Thanks for your responses.

I was looking on the Family Historian website which is identical except that the "Family Historian Plugin Help" link on the "Plugins Dialog" page doesn't work (or is it for just me?). So the provided link is very helpful! Thanks @ColeValleyGirl

@Tatewise's guidance as to the right expression is super helpful. I was trying to use the Columns/Fields pane - thanks for the tip re Show Both in Box - but e.g. %INDI.BURI.SOUR.DATA.TEXT% was not an option in that pane. Now the penny has dropped...that you have to use that as a scaffold and then add the relevant GEDCOM tag. If that is in the manual then I missed it!

Thanks all :-)

Talln

PS Why am I doing this? For fun! I built my own website back in 2003 and it's due a revamp. The standard FH web offering is too slow, too fat (8000+ pages for me) and too porous out of the box (and the sanitising workflow is not for me), so I'm simultaneously (re-)learning and coding in html, javascript, css, lua, sql, mtaccess, php and FH api functions. My target is to run one FH plugin and upload a set .csv files to my website database, with any new images - automatically using a cron job - so the day's "work" is safely uploaded with minimal effort. Or I could just upload to a commercial site...but where's the fun in that!
Paul Weaver, London

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Querying Source Citations

Post by tatewise » 16 Mar 2022 14:34

I don't understand why you say %INDI.BURI.SOUR.DATA.TEXT% was not an option in the Fields pane, and you have to use that as a scaffold...
Shown below is how that data reference is derived from the Fields pane. However, you need to expand all the appropriate [+] buttons, especially as Text from Source is hidden inside (Data) for which you have to blame the GEDCOM specification.

QueryColumnsFields.png
QueryColumnsFields.png (38.66 KiB) Viewed 880 times
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Talln
Gold
Posts: 18
Joined: 09 Feb 2021 17:15
Family Historian: V7
Location: London

Re: Querying Source Citations

Post by Talln » 16 Mar 2022 17:28

Aaaahhh! I was looking at the duplicate entries without the parentheses, thinking those were the main/complete entries! :shock: I would imagine there's a really good explanation for that and for the colour scheme of the bullets, but I've taken enough of your time!

Thanks again!

Talln
Paul Weaver, London

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Querying Source Citations

Post by tatewise » 16 Mar 2022 18:14

The entries without the parentheses are the Source record (SOUR>) fields as opposed to the Citation-specific fields.
Which are the main/complete ones is debatable :D

The colour scheme for the bullets identifies the type of record and matches the colour scheme in the Records Window and on the All tab of Property Boxes when expanded in a similar fashion.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply