* Existence of a field definition in Source Template

Questions about Generic and Templated Sources within FH and their associated Citations and Repositories
Post Reply
avatar
Medows
Gold
Posts: 16
Joined: 16 May 2016 12:28
Family Historian: V7

Existence of a field definition in Source Template

Post by Medows » 22 Jun 2023 10:05

Hello,
I apologise if I have already asked this but VirginMedia have loats all my emails and therefore questions I have asked in FHUG.
I am looking to check for the existence of 2 common field definitions I have in my Source Templates. Yes I could go through them one at a time but I was looking for a more automated way.
In each of my templates I have 2 defintions - Research Date, Research Place. I have found one where I put the Resaerch Place before the Research Date and I think there may be one or two where I have not put these in at all. I use them for my personal use to know when and where I have been on my travels.

A source template of course has a variable number of Field Definitions (FDEF) which means I can't put in a code such as...
%_SRCT.FDEF[2]% - because this is the second field within that template.

So I would like to know the following...
Template name, Collection, position of "Reseach Date", position of "Research Place, number of links and possibly the type of field the research date and reseach place.

When writing templates I strive for consistency but there are 3 of us (myself, wife and daughter) creating these templates but we do keep a master copy between us.

Is what I am asking for possible?

Alan

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

Re: Existence of a field definition in Source Template

Post by ColeValleyGirl » 22 Jun 2023 10:35

The Help File section on Data References And Metafields (scroll down) give ypu the information ypu need to reference the metafields via their names and not their position.

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

Re: Existence of a field definition in Source Template

Post by tatewise » 22 Jun 2023 10:45

Helen, I don't think that provides the position of a metafield and does not work in Source Templates only in Source records.

Yes, Alan, I think you can achieve most if not all your requirements.

Focus on the Records Window, Source Templates tab which by default lists Template Name, Collection, and Links, etc.

To determine the position and existence of a metafield definition needs a nested set of TextIf(...) functions.

Use Lists > Configure Record Window Columns... or right-click the heading and choose Configure Columns...
In the Configure Columns dialogue select <Other...> and add > to Columns on right.
In the Heading enter the Name of your field Research Date.
In the Expression enter the following:
=TextIf(%_SRCT.FDEF.NAME% = "Research Date","1", TextIf(%_SRCT.FDEF[2].NAME% = "Research Date","2", TextIf(%_SRCT.FDEF[3].NAME% = "Research Date","3", TextIf(%_SRCT.FDEF[4].NAME% = "Research Date","4", "?"))))
If its position may be beyond the 4th field definition then more nested TextIf(...) functions are needed.
If you know its lowest position then some of the earlier TextIf(...) functions are not needed.

Repeat the whole process for Research Place. The easiest way is to copy the Expression into a plain text editor, use Find & Replace to change the word Date to Place and paste it into the new Expression.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Existence of a field definition in Source Template

Post by Mark1834 » 22 Jun 2023 10:45

Two options:

Create a new custom query of type Source Template, and list each field definition in sequence. You can then either inspect manually or export the results to file.

Alternatively, inspect the definition file directly, which is stored at C:\ProgramData\Calico Pie\Family Historian\Source Templates\Custom, with one file for each collection. If you open the collection file with a text editor (Notepad is fine), you can use the usual text search function to locate names of interest. It does not give the position explicitly, but fields are listed in order for each template.

Be careful not to change the file, so it is probably safer to create a copy first and work from that.

edit - posted simultaneously with Mike, but I think my version is a lot less typing :)
Mark Draper

avatar
Medows
Gold
Posts: 16
Joined: 16 May 2016 12:28
Family Historian: V7

Re: Existence of a field definition in Source Template

Post by Medows » 22 Jun 2023 16:18

Thank you everybody for your suggestions. I eventually used Mike's solution as it was more automatic especially after initial setup.

Alan

User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Existence of a field definition in Source Template

Post by Mark1834 » 22 Jun 2023 17:22

No problem, but make sure that you understand exactly what the functions are doing rather than just copying them blindly, as you will then be able to use and adapt them for other similar scenarios in the future.
Mark Draper

avatar
Medows
Gold
Posts: 16
Joined: 16 May 2016 12:28
Family Historian: V7

Re: Existence of a field definition in Source Template

Post by Medows » 22 Jun 2023 17:34

Thanks for that remark. I do understand them.

Post Reply