This version is out of date, covering development from v5.0.0 to v5.12.2. It is maintained here only for inbound reference links from elsewhere.

Jump to the current version of aTbRef.

Tinderbox Icon

Renaming an attribute

Attribute names are case-sensitive and chan't be changed once made. Either typing errors when making attributes or or import auto-generated attributes may result in attribute names that are wrong or even just in the wrong casing.

Consider the scenario where an author's name is stored in an attribute called 'AuthorName' and an import of tab-delimited data has resulted in an attribute 'author'. Before making changes, if the attributes you need to change are used in actions, templates, etc., then you should temporarily turn off all agents before preceding.

Create an agent, set to locate all items with data in the 'wrong' attribute and with an action to copy the attribute's data to the 'right' attribute. So, for the example above:

Query: $author

Action: $AuthorName = $author

Check specimen data to ensure it has transferred as intended, then delete the agent and the 'incorrect' attribute, which is not longer required. User attributes are deleted via the Attributes dialog. Lastly, don't forget to correct any references to the old 'wrong' attribute name, most likely in Action-type attributes, ^export^ codes, or $TableHeading. You can always make one or more temporary agents to search these attributes case-sensitively for the 'wrong' attribute names, e.g. $Rule.contains("author"). Depending on the common ness of the 'bad' name value, you may want to visually inspect matches and correct them rather than allow an agent action to run automatically. For instance, "author" might be a bona fide word in a note's $Text that should - unlike a reference to $author in code - be updated; such ambiguities likely need inspection by eye to resolve but an agent can at least find specimen matches.

If the task is simply to rename an existing attribute, first make the new, correctly named, attribute (of the correct data type, too). Then proceed as above.

With List or Set type data you should consider a slightly different agent action:

Action: $GoodSet = $badset

Action: $GoodSet = $GoodSet + $badset

In the first case existing values in $GoodSet are overwritten entirely whereas in the second case the values of both sets are merged, adding to $Goodset's values.

String and Number type data also be merged. With Strings, consideration must be given to whether the existing data ends with punctuation and or a space and thus whether any joining literal string e.g. ". " needs adding between old and new data.

Action: $AuthorName = $AuthorName + ". " + $author

With Numbers, a 'merge' is effectively an addition (though other operators could be used):

Action: $GoodNumber = $GoodNumber + $badnumber


Possible relevant notes (via "Similar Notes" feature):


A Tinderbox Reference File : Attributes : Renaming an attribute