I have not attempted creating a "Plug In" before so very much need your help.
I am a coordinating a one name study and have a heavy reliance on the Custom ID field to allocate unique references that can be alpha numeric in construction. These are allocated to individuals.
The problem that I have encountered is the inability to generate a descendants report where Custom IDs are identified against an individual.
I have been informed that writing a PlugIn may resolve this.
Any help would be appreciated.
Best regards
Trevor
* Using custom IDs
- tatewise
- Megastar
- Posts: 27080
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Using custom IDs
Hello Trevor, the general plan is as follows:
Use Tools > Work With Fact Sets > New with Fact Name = Custom Id and Fact Type = Attribute and Record Type = Individual.
Either leave Fact Set = Custom or perhaps set it to Custom Id and click Create.
You may wish to disable some Fields Required such as Age and Place and Address.
(If you choose a different Fact Name than Custom Id then the Plugin text "Custom Id" must be changed likewise.)
2. Set the Sentence Template
Something like {label} = {value} will produce Cutom Id = ABC123. in Reports.
This can be adjusted later to produce just what you want.
3. Set the Normal Time Frame
Set this to Pre-Birth to come first, or Post-Death to come last, among other Facts.
This can be adjusted later to position it just where you want, or you can add a Date to the Attribute to position it among other Facts.
4. The Plugin
To create the Plugin use Tools > Plugins > More>> > New and copy & paste the code below into the editor.
Use File > Save As > Plugin Name = Copy Custom Id To Attribute.
Then close the editor, select the Plugin name and tick Add to Tools Menu.
To run the Plugin use Tools > Copy Custom Id To Attribute and repeat whenever Custom Id Attributes need updating.
One word of caution: Every Individual Record that requires a new Custom Id Attribute, will have its Updated date - updated!
The following code should do the job:
- You create a Custom Attribute Fact to hold the Individual Custom Id as its value.
- Set its Sentence Template appropriately for the Narrative Reports.
- Set its Normal Time Frame to position the Custom Attribute among other Facts.
- Run a Plugin to copy each Individual Custom Id to its Custom Attribute Fact value.
Use Tools > Work With Fact Sets > New with Fact Name = Custom Id and Fact Type = Attribute and Record Type = Individual.
Either leave Fact Set = Custom or perhaps set it to Custom Id and click Create.
You may wish to disable some Fields Required such as Age and Place and Address.
(If you choose a different Fact Name than Custom Id then the Plugin text "Custom Id" must be changed likewise.)
2. Set the Sentence Template
Something like {label} = {value} will produce Cutom Id = ABC123. in Reports.
This can be adjusted later to produce just what you want.
3. Set the Normal Time Frame
Set this to Pre-Birth to come first, or Post-Death to come last, among other Facts.
This can be adjusted later to position it just where you want, or you can add a Date to the Attribute to position it among other Facts.
4. The Plugin
To create the Plugin use Tools > Plugins > More>> > New and copy & paste the code below into the editor.
Use File > Save As > Plugin Name = Copy Custom Id To Attribute.
Then close the editor, select the Plugin name and tick Add to Tools Menu.
To run the Plugin use Tools > Copy Custom Id To Attribute and repeat whenever Custom Id Attributes need updating.
One word of caution: Every Individual Record that requires a new Custom Id Attribute, will have its Updated date - updated!
The following code should do the job:
Code: Select all
--[[
@Title: Copy Custom Id To Attribute
@Author: Mike Tate
@Version: 1.0
@LastUpdated: 02 Nov 2013
@Description: Copy every Individual Custom Id to a Fact Attribute Value.
]]
-- Determine the Custom Id Attribute Fact Tag
local strFactTag, strError = fhGetFactTag("Custom Id", "Attribute", "INDI", true)
if strError ~= nil then
error("Error Creating Custom Id Attribute Tag\n"..strError)
end
local ptrIndi = fhNewItemPtr()
ptrIndi:MoveToFirstRecord("INDI")
while ptrIndi:IsNotNull() do -- Loop through Individual Records
ptrRefn = fhGetItemPtr(ptrIndi,"~.REFN")
strRefn = fhGetValueAsText(ptrRefn) -- Get the Custom Id value
ptrAttr = fhGetItemPtr(ptrIndi,"~."..strFactTag)
strAttr = fhGetValueAsText(ptrAttr) -- Get the Custom Id Attribute value
if strRefn ~= strAttr then -- Custom Id equals Attribute?
if ptrAttr:IsNull() then
ptrAttr = fhCreateItem(strFactTag,ptrIndi) -- Create new Custom Id Attribute Fact
if ptrAttr:IsNull() then
fhMessageBox("Error creating Custom Id : '"..strRefn.."' Attribute for "..fhGetDisplayText(ptrIndi))
return
end
end
fhSetValueAsText(ptrAttr,strRefn) -- Save new Custom Id Attribute value
end
ptrIndi:MoveNext()
end
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- TeaSeaPea
- Gold
- Posts: 10
- Joined: 02 Nov 2013 12:16
- Family Historian: V6
- Location: Beckenham, Kent, England
- Contact:
Re: Using custom IDs
Mike,
Thank you very much.
I will give this a go when I get back from holiday.
Best regards
Trevor
Thank you very much.
I will give this a go when I get back from holiday.
Best regards
Trevor