I am trying to attach a NoParents Flag to an individual but am having some difficulty.
I can create the Flag by using:
strNewFlag='NoParents'
strTag, strError = fhGetFlagTag(strNewFlag,true)
but I cannot work out how to assign the flag to an individual.
I have searched this Forum and the Help file without success.
Also I cannot find anything in the samples or the Plugin store to help.
I would appreciate a nudge in the right direction please.
tia
Mike
* Attach a Flag to an Individual
Attach a Flag to an Individual
Regards
MikeJ
MikeJ
- tatewise
- Megastar
- Posts: 27076
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Attach a Flag to an Individual
Here is a snippet of code to add a Flag:
This does not have any IsNull() checks to ensure created items are successful, nor if the "NoParent" Flag already exists.
I leave that for you to develop.
However, this begs the question ~ Why do you want to set NoParent Flags?
The expression =Exists(%INDI.FAMC[1]%) essentially does the same job more efficiently, and automatically is correct without having to manually run a Plugin or Query to set Flags.
This expression can be used to condition a Records Window Column, or a Diagram Icon, or a Query filter, etc, etc.
See how_to:using_flags_and_icons|: Using Flags and Icons for much more detail.
Code: Select all
local ptrRec = fhNewItemPtr() -- Obtain an Individual Record pointer for demo
ptrRec:MoveToFirstRecord("INDI")
strTag, strError = fhGetFlagTag("NoParent", true) -- Obtain tag for "NoParent" Flag
ptrFlgs = fhGetItemPtr(ptrRec, "~._FLGS") -- Check "_FLGS" tag
if ptrFlgs:IsNull() then
ptrFlgs = fhCreateItem("_FLGS", ptrRec) -- Create "_FLGS" tag if necessary
end
ptrFlag = fhCreateItem(strTag, ptrFlgs) -- Create the "NoParent" Flag
I leave that for you to develop.
However, this begs the question ~ Why do you want to set NoParent Flags?
The expression =Exists(%INDI.FAMC[1]%) essentially does the same job more efficiently, and automatically is correct without having to manually run a Plugin or Query to set Flags.
This expression can be used to condition a Records Window Column, or a Diagram Icon, or a Query filter, etc, etc.
See how_to:using_flags_and_icons|: Using Flags and Icons for much more detail.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
- Jane
- Site Admin
- Posts: 8440
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: Attach a Flag to an Individual
I have added Mike's example to the code snippets with a few changes
plugins:code_snippets:flags_add_and_remove_function|setFlag Function
plugins:code_snippets:flags_add_and_remove_function|setFlag Function
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
Re: Attach a Flag to an Individual
Mike
Thank you very much for the info. That worked perfectly!
I can see where I was going wrong now. I was trying to create the "NoParent" flag without first creating the "_FLGS" tag.
Re your question as to why.
I wish to set the flag as part of my Census csv import plugin. Setting a flag when a combination of circumstances occurs will highlight the need for closer inspection after import.
In this instance when a Son or Daughter (relation to hoh in census) is imported without a Parent having been assigned to them.
Thanks once again.
MikeJ
Thank you very much for the info. That worked perfectly!
I can see where I was going wrong now. I was trying to create the "NoParent" flag without first creating the "_FLGS" tag.
Re your question as to why.
I wish to set the flag as part of my Census csv import plugin. Setting a flag when a combination of circumstances occurs will highlight the need for closer inspection after import.
In this instance when a Son or Daughter (relation to hoh in census) is imported without a Parent having been assigned to them.
Thanks once again.
MikeJ