Page 1 of 1

Querying Source Citations

Posted: 15 Mar 2022 18:41
by Talln
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...

Re: Querying Source Citations

Posted: 15 Mar 2022 18:47
by ColeValleyGirl
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)

Re: Querying Source Citations

Posted: 15 Mar 2022 20:03
by tatewise
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?

Re: Querying Source Citations

Posted: 15 Mar 2022 20:47
by AdrianBruce
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?

Re: Querying Source Citations

Posted: 16 Mar 2022 14:03
by Talln
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!

Re: Querying Source Citations

Posted: 16 Mar 2022 14:34
by tatewise
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 891 times

Re: Querying Source Citations

Posted: 16 Mar 2022 17:28
by Talln
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

Re: Querying Source Citations

Posted: 16 Mar 2022 18:14
by tatewise
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.