Topic
11 replies Latest Post - ‏2015-03-12T21:33:53Z by ChrisHardy68
SystemAdmin
SystemAdmin
3180 Posts
ACCEPTED ANSWER

Pinned topic Rename an existing attribute

‏2009-05-05T12:51:50Z |
OK, I admit it, I'm defeated.

Anyone know how to rename an existing attribute using DXL ?

No changes to the base type, or contents, just the name.

And it has to be the actual attribute name, not just the display name, or column name.

Mucho Thanko.

Andrew.
Updated on 2009-05-11T16:07:18Z at 2009-05-11T16:07:18Z by llandale
  • llandale
    llandale
    2943 Posts
    ACCEPTED ANSWER

    Re: Rename an existing attribute

    ‏2009-05-05T13:20:00Z  in response to SystemAdmin
    Looks like this:
    AttrDef adOld = find(mod, "MyOldName")
    AttrDef adNew = modify(adOld, setName, "MyNewName")
    • SystemAdmin
      SystemAdmin
      3180 Posts
      ACCEPTED ANSWER

      Re: Rename an existing attribute

      ‏2009-05-06T13:03:45Z  in response to llandale
      Hmmm, gave me an exception error in v8.3 louie (which I helpfully added to your compendium of errors in the other thread). However will play with this tomorrow again, could be I just got something else wrong.

      I did find another workaround in the meantime, Just create a 'shadow' attribute of the same underlying type but with the new name, copy accross all the values, delete the original. Simplissimo.

      If you are wondering why I want to do this, it's because the Word import macro that comes with DOORS (the one that adds an import icon to the word doc) can helpfully import the Word paragraph styles into DOORS, however it puts them into a string attribute called 'Paragraph Style' - however all my modules already have a 'Parargaph Style' enumerated attribute.

      This is Ok most of the time, but for instance if my word doc has been to france and back (which many of mine do), then 'body text' is now 'corps something-or-other', most annoying.

      So I have to rename 'my' attribute before import, let the importer do its thing with the string based 'Paragraph Style' attrib, then monkey around with a post processing script to normalise everything afterwards.

      Fun fun fun.

      I'll say one thing for DOORS admin work, it never gets boring.
      • llandale
        llandale
        2943 Posts
        ACCEPTED ANSWER

        Re: Rename an existing attribute

        ‏2009-05-06T15:57:48Z  in response to SystemAdmin
        Its working for me in v8.3. Getting null attrdef if the attr doesn't exist; getting 'no access' errors if the module is open read.

        Its 'Simplyannoyingo': you have to reinsert the attribute in all the views.

        I think you should change your 'Paragraph Style' attribute name in your modules and let the importer do its thing. That's sort of a 'system' attr, like 'RTF Header'.

        >Louie
        • SystemAdmin
          SystemAdmin
          3180 Posts
          ACCEPTED ANSWER

          Re: Rename an existing attribute

          ‏2009-05-08T08:47:22Z  in response to llandale
          Works just fine today, obviously I had ham fists when I typed it in the other day.

          Thanks Louie, and yep, I do need to go rename that attribute in my 5,000 or so modules,and then update all teh sctipts that use it, arrrrgh!
          • llandale
            llandale
            2943 Posts
            ACCEPTED ANSWER

            Re: Rename an existing attribute

            ‏2009-05-08T13:17:25Z  in response to SystemAdmin
            The script to update your modules is pretty easy, and can probably finish overnight so long as you periodically close all residual open modules in the database.

            Turns out searching *.dxl files using Windows Explorer stopped working for me last month. Security here says it wasn't them. Cannot find it on the Windows update site. Anyway, I played with the Registry and figured out how to make it search those files.

            >Louie
            • Ben_Sharples
              Ben_Sharples
              16 Posts
              ACCEPTED ANSWER

              Re: Rename an existing attribute

              ‏2009-05-11T05:04:19Z  in response to llandale
              where you have a common set of attributes across many modules in the databse, it may be useful to house the attributes names within a separate dxl include file that you can reference in all you dxl programmes - saves on modifying all of them everytime an attribute name changes.

              I usually define my attribute names as strings to use in the programme parts of the dxl - that way its easier to update.
              • llandale
                llandale
                2943 Posts
                ACCEPTED ANSWER

                Re: Rename an existing attribute

                ‏2009-05-11T16:07:18Z  in response to Ben_Sharples
                Or have a template module that has your attributes in it.
                • Martin_Hunter
                  Martin_Hunter
                  40 Posts
                  ACCEPTED ANSWER

                  Re: Rename an existing attribute

                  ‏2014-04-17T06:45:00Z  in response to llandale

                  I want to rename an attribute, however I also want to update all views which contain the old attribute. 

                  I think I have to first rename 'old' attribute to 'new' attribute, then temporarily recreate 'old' attribute to enable me to update any affected views, after which I can delete the temporary 'old' attribute.

                  Or is there a simpler way?

                  • llandale
                    llandale
                    2943 Posts
                    ACCEPTED ANSWER

                    Re: Rename an existing attribute

                    ‏2014-04-17T14:37:36Z  in response to Martin_Hunter

                    I like a template module that you fix; then use script "copyViews.dxl" to push to the rest of the modules.  the script "copyAtts.dxl" won't help you rename an attribute.  Google those scripts.

                    But if you want a script to fix any particular module, I don't think your approach will work.  I think (but not sure) the attr will get removed from some non-displayed view when you rename it and before you have a chance to create the old attr at the same name.  I think then you need to plow through all the views and "remember" which view has the old attribute, in which colulmn and other column attributes (width); rename the attr, then plow through the views re-inserting the new.

                    You could also create the new attribute, copy all the values of objects over, then plow through the views changing the column, then delete the old.  That will mess up History however; even more so then renaming the attribute.

                    -Louie

                  • This reply was deleted by llandale 2014-04-17T14:49:00Z. Reason for deletion: Duplicate post oops
                  • This reply was deleted by llandale 2014-04-17T14:49:16Z. Reason for deletion: duplicate post oops
                  • llandale
                    llandale
                    2943 Posts
                    ACCEPTED ANSWER

                    Re: Rename an existing attribute

                    ‏2014-04-17T14:49:18Z  in response to Martin_Hunter

                    I like a template module that you fix; then use script "copyViews.dxl" to push to the rest of the modules.  the script "copyAtts.dxl" won't help you rename an attribute.  Google those scripts.

                    But if you want a script to fix any particular module, I don't think your approach will work.  I think (but not sure) the attr will get removed from some non-displayed view when you rename it and before you have a chance to create the old attr at the same name.  I think then you need to plow through all the views and "remember" which view has the old attribute, in which colulmn and other column attributes (width); rename the attr, then plow through the views re-inserting the new.

                    You could also create the new attribute, copy all the values of objects over, then plow through the views changing the column, then delete the old.  That will mess up History however; even more so then renaming the attribute.

                    -Louie

        • ChrisHardy68
          ChrisHardy68
          7 Posts
          ACCEPTED ANSWER

          Re: Rename an existing attribute

          ‏2015-03-12T21:33:53Z  in response to llandale

          Hi,

          i had a similar issue where i had to rename a number of attributes that were all used in multiple views. Luckily the change impacted only a few modules.

          I worked around the issue by:

          Create a dummy attribute

          For the attribute to be renamed find the views and the related columns where it is used in

          For those columns replace the attribute with the dummy attr

          Save the view

          Rename the attribute

          For those columns replace the dummy attribute with the renamed attr

          Save the view

          Not very elegant but it worked for me. I can share the code if required

           

          Updated on 2015-03-12T21:35:01Z at 2015-03-12T21:35:01Z by ChrisHardy68