Attribute names are case-sensitive. Unlike previous versions, User [sic] attributes can be renamed and re-data-typed after creation. System attributes cannot be renamed or have their data type changed. A rename might be to use a completely different term, e.g. $Cost renamed to $Price, or it might be a change of case, $cost to $Cost.
Simply select the attribute in the Document Inspector's User tab, select the name, enter a new value and press Return. Attribute listings and Displayed Attributes entries will update. However, any explicit use of the old name in action or export code, templates, boilerplate code, etc., will be unaffected. Such mentions must be manually edited to reflect the change but do not overlook agents as a help to find such code passages for correction. Places where you may need to manually change attribute names:
- Action-type system attributes.
- Action code in code notes.
- Stamps.
hasLocalValue("Price")
. This will match all notes that have a (local, not inherited) value set for the existing Price attribute. If you have a prototype that sets a value inherited b other notes, only the prototype will match as well as notes that have a value set deliberately in that note.
* Check the agent matches to sort of notes expected: this is good to do before diving straight in to copying any values. If all looks good…
* Set an agent action $TotalPrice = $Price
. For each matched note—and only matched notes—the value of the $TotalPrice attribute is set to the notes existing $Price value.
* At this point both attributes in matching notes have a value, and the same one. This is another opportunity to check things look good if trying this for the first time (Outline column view can help). Assuming all looks good…
* Delete the agent. Do not forget this step!
* Open the Document Inspector's User tab, and select the 'Price' attribute. Using the gear-wheel button (at right) from the pop-up choose the 'Delete user attribute' option. The 'Price' attribute is deleted along with any data.
* Other tidy-up issues:
** Displayed Attributes. If $Price was used as a Displayed Attribute you will need to use an agent to find and remove the old name and add the new one.
** Action code. Review code in Stamps and any Action-type attributes (e.g. $Rule, $AgentAction, etc.) to find and remove the old name and add the new one.
Changing data type
If changing the data type of an attribute, consider coercion effects:
* To Boolean. No value: false
. All other values: true
.
* String-based to Number. Strings of number characters: numbers. All other strings: no value.
* Number to string-based. Numbers become literal strings.
* To/from Date. Date to String will likely give the date in string form as would be shown in Displayed Attributes in the current TBX. Other type conversions may have variable effects, e.g. Date to Number which is not a sensible change, anyway.
* List or Set to String. A semi-colon concatenated string of list values.
* String to List or Set. The current string will split to list values at any semi-colons in the original value.
* To/From Interval. Not documented.
Bear in mind that Colour, URL and File types are essentially String type with a special form of handling
See also—notes linking to here: