Indeed, there isnât a âmergeâ operator. But this is toolbox. We donât have a 'putUpShelf() function but we do have a drill, and screwdriver and a spirit level, etc. So with the latter in mindâŚ
The general pattern here, is to merge attribute MyY with attribute MyX values and then delete MyY. So we make
- an agent to find all notes with a value for MyY, i.e. query is:
$MyY
- code to merge MyY into MyX. Take care if either MyX or MyY is intrinsic as youâll need to merge the originalsâ values and not the aliases.
- once done and checked, delete the agent and then delete user attribute Y. If you do use attribute descriptions, consider updating MyXâs description to include any new MyY-related aspects now stored in MyX.
How about the merge?
Merging two String-types:
$MyXString = $MyXString + $MyYString;
You might want to add a join string, e.g. " :: ":
$MyStringX = $MyStringX + " :: " + $MyStringY;
The top might merge âGreenâ and âHamâ to âGreenHamâ whereas the second would give âGreen :: Hamâ. You could also put the Y value first:
$MyStringX = $MyStringY + " :: " + $MyStringX;
giving âHam :: Greenâ.
Merging into a Set-type:
$MySetX = $MySetX + MySetY;
As the recipient is a Set-type duplicates are removed for you.
Merging into a List-type:
$MyListX = $MyListX + MySetY + $MyListZ;
$MyListX = $MyListX.unique;
If necessary you could sort the MyListX list as well.
Adding a String type to a Set or list:
$MyListX = $MyListX +$MyStringY;
$MyListX = $MyListX.unique;
or
$MySetX = $MySetX +$MyStringY;
âŚand so on.
Does that help. Donât forget to delete the merged-and-not-needed attribute_but_ only after youâve checked the merged data looks right!