* Creating a citation for a source

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
avatar
mitcheip
Diamond
Posts: 66
Joined: 21 Aug 2014 08:37
Family Historian: V7

Creating a citation for a source

Post by mitcheip » 20 Dec 2017 19:42

Hi,

I have a CSV file of information, (5 columns) and I want to write a plugin to process the file. I want to-

Read in the file, (done with one of the available code snippets)
Read thro' the file
If the row has valid data (Column 5 has a one in it)
Move to the Person who's Record Id is in Col 2
Create a Citation for Source No 1041 against the <whole record>* for that person (rather than a particular event)
Populate "Where In Source" Field with some Text

below is part of the code for the plugin that is set up to read just the first 3 records in the file to start with. It runs without error but doesn't do what I have described above. Any ideas why not? ( I think I'm not getting the right ptrCite....

--> Load CSV with file with header

local lines,titles = table.loadcsv('C:\\Users\\Ian Mitchell.ianmitcell-PC\\Downloads\\filetablist.csv',true)
for i=1, 3 do
if lines[titles[5]]=="1" then
sName = (lines[titles[1]])
sId = (lines[titles[2]])
iId = tonumber(sId)
sTab = (lines[titles[3]])
sFile = (lines[titles[4]])
sText = "File "..sFile.." Tab "..sTab
ptrIndi = fhNewItemPtr() --> moving to record for individual in file using the ref number
ptrIndi:MoveToRecordById('INDI',iId)
ptrSource=fhNewItemPtr() --> moving to record for the Source "Phyiscal File" which is source number 1041
ptrSource:MoveToRecordById('SOUR',1041)
--> record the citation record for the 1041 Source against the whole record for the individual, (not a particualar event)
ptrCite=fhCreateItem('SOUR',ptrIndi)
ptrField=fhCreateItem('PAGE',ptrCite)
fhSetValueAsText(ptrField,sText)
end
end

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

Re: Creating a citation for a source

Post by tatewise » 20 Dec 2017 20:58

If you check the All tab for the Individuals you will find it has done everything defined by the Plugin script.

The one thing you have not done is link the Citation to the Source record:
fhSetValueAsLink(ptrCite,ptrSource)
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
mitcheip
Diamond
Posts: 66
Joined: 21 Aug 2014 08:37
Family Historian: V7

Re: Creating a citation for a source

Post by mitcheip » 21 Dec 2017 11:32

Thanks a lot, Mike, that worked!!!!

Post Reply