Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Changing an Attribute (Read 1693 times)
Simon Smailus
Full Member
*
Offline



Posts: 141
Tipton, UK
Changing an Attribute
Jun 24th, 2014, 5:23am
 
I've created an attribute called "eventdate". I realised that I want a capitalised naming convention, "EventDate". However changing this removes all the data stored in that attribute.

Is it possible to change an attribute without losing the content of notes that already use the attribute?
Back to top
 
 

Simon Smailus
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Changing an Attribute
Reply #1 - Jun 24th, 2014, 6:40am
 
Quote:
Is it possible to change an attribute without losing the content of notes that already use the attribute?


You can change the data-type of an existing attribute but it's something to do with care and really only works for going to String-type. Anyway, that's not your problem here.

Yu can't change the name of an existing attribute as you effectively add a new one: $eventdate, $EventDate, $EVENTDATE, etc. Are all different valid attribute names. But it is easy to fix this:
  • Make an $EventDate attribute, ensuring the correct data type. (Assumption: both old/new attributes use the same data-type, e.g. both Date or both String, etc.)
  • Make an agent (as explained below) to find all notes with a non-default value for $eventdate. For each match, set the value of $EventDate to be the value of $eventdate.
  • Check sufficient notes' data so as to be happy the data is copied across. If not, rinse & repeat until correct.
  • Delete the agent.
  • Delete the $eventdate attribute.
  • Make sure you update any use of $eventdate in existing actions/rules to reflect the new $EventDate name. TB will not do the latter task for you.
For the agent, use these values:

Query:   $eventdate
Action:   $EventDate = $eventdate

~~~~~~~~~~~~~
Unless you're an experienced coder with strong reasons to use a different convention, I recommend all new users of TB action code, follow the TB attribute naming convention of 'CamelCase' names, i.e. initial capital and captialise joined words: $Border, $WordCount. For acronyms, $MyURL or $MyUrl would be fine. The point is that if you adopt a rule, akin to the used by the app, code samples will make more sense and you're more likely to sport mistakes in your action code.

This isn't a requirement. Experienced coders may use several coding languages and have developed their own styles. That's fine as they're less likely to have the new-to-actions-and-coding persons problem of everything just looking strange. for the latter, some gently self-imposed constraints can aide ease of use.
Back to top
 
« Last Edit: Jun 24th, 2014, 6:46am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Simon Smailus
Full Member
*
Offline



Posts: 141
Tipton, UK
Re: Changing an Attribute
Reply #2 - Jun 24th, 2014, 6:52am
 
Superb! Thank you.

As an aside. I've noticed in TB 6 that if you accidentally change the attribute name, easily done as it's counterintuitive for me to hit the "New User Attribute" before typing the name, it does actually change the attribute name in use. Is this intended behaviour?
Back to top
 
 

Simon Smailus
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Changing an Attribute
Reply #3 - Jun 24th, 2014, 7:08am
 
Ah, yes it does!. I don't think this is by intent (I've reported it as an issue, anyway). As you say, this makes it far too easy to screw up existing work. So for now, take care!
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print