Topic
  • 4 replies
  • Latest Post - ‏2013-11-06T13:51:52Z by mcnairk
mcnairk
mcnairk
111 Posts

Pinned topic Setting an attribute to a default value for new objects only

‏2013-11-05T18:59:46Z |

I have a multi-valued attribute with no current default. Some objects are set to non-default values; some have the default (blank). I want to set a default value for new objects only without affecting the existing objects. I can't seem to find a way to do this without introducing a new value (e.g. "N/A") for the objects that are currently blank.

Any suggestions on how to solve this problem?

Thanks,

             Ken.

  • llandale
    llandale
    2985 Posts
    ACCEPTED ANSWER

    Re: Setting an attribute to a default value for new objects only

    ‏2013-11-05T20:51:21Z  

    I know of no way of changing the behavior that "null values" are the ones that get defaulted.  I would like to point out, however, that "defaulted" values (and "inherited" values) are not actually set, they just APPEAR to have the default value.  function "hasSpecificValue" can distinquish between a defaulted value and a value that is the same as the default.

    Anyway, instead of new value "N/A" you could have new value " " (a space).

    Tryiing to simulate a object-create trigger and setting the value explicitely is not realistic.

    -Louie

  • llandale
    llandale
    2985 Posts

    Re: Setting an attribute to a default value for new objects only

    ‏2013-11-05T20:51:21Z  

    I know of no way of changing the behavior that "null values" are the ones that get defaulted.  I would like to point out, however, that "defaulted" values (and "inherited" values) are not actually set, they just APPEAR to have the default value.  function "hasSpecificValue" can distinquish between a defaulted value and a value that is the same as the default.

    Anyway, instead of new value "N/A" you could have new value " " (a space).

    Tryiing to simulate a object-create trigger and setting the value explicitely is not realistic.

    -Louie

  • mcnairk
    mcnairk
    111 Posts

    Re: Setting an attribute to a default value for new objects only

    ‏2013-11-05T21:46:58Z  
    • llandale
    • ‏2013-11-05T20:51:21Z

    I know of no way of changing the behavior that "null values" are the ones that get defaulted.  I would like to point out, however, that "defaulted" values (and "inherited" values) are not actually set, they just APPEAR to have the default value.  function "hasSpecificValue" can distinquish between a defaulted value and a value that is the same as the default.

    Anyway, instead of new value "N/A" you could have new value " " (a space).

    Tryiing to simulate a object-create trigger and setting the value explicitely is not realistic.

    -Louie

    Pretty much what I expected, but I'm not sure that your suggestion of a dummy value works. At least not when I tried it on DOORS 8.2. I created a new value of " " (a space), set an object to have this value, and then set a default. Much to my disappointment, it got changed to the default. I can try this on 9.5 but don't expect it to work any different.

    I thought about as trigger for a microsecond, but they are the devils work and to be avoided at all costs!

    Thanks,

    Ken.
  • Mathias Mamsch
    Mathias Mamsch
    1983 Posts

    Re: Setting an attribute to a default value for new objects only

    ‏2013-11-06T11:28:16Z  
    • mcnairk
    • ‏2013-11-05T21:46:58Z
    Pretty much what I expected, but I'm not sure that your suggestion of a dummy value works. At least not when I tried it on DOORS 8.2. I created a new value of " " (a space), set an object to have this value, and then set a default. Much to my disappointment, it got changed to the default. I can try this on 9.5 but don't expect it to work any different.

    I thought about as trigger for a microsecond, but they are the devils work and to be avoided at all costs!

    Thanks,

    Ken.

    The method of replacing default values by a real value works - we did this a lot during migrations with DOORS 8 and I just did it again on DOORS 9.4. Create an Enum Type with Values A,B,N/A. Create an attribute of it, set default value A. Set one object to A, one object to B leave the rest at default (A). Then change the attribute default to N/A. You should still have one object with Value A, one with Value B. If this would not work, something would be very wrong. But it seems you will indeed not solve your problem without introducing a new value N/A or " ". Regards, Mathias

  • mcnairk
    mcnairk
    111 Posts

    Re: Setting an attribute to a default value for new objects only

    ‏2013-11-06T13:51:52Z  

    The method of replacing default values by a real value works - we did this a lot during migrations with DOORS 8 and I just did it again on DOORS 9.4. Create an Enum Type with Values A,B,N/A. Create an attribute of it, set default value A. Set one object to A, one object to B leave the rest at default (A). Then change the attribute default to N/A. You should still have one object with Value A, one with Value B. If this would not work, something would be very wrong. But it seems you will indeed not solve your problem without introducing a new value N/A or " ". Regards, Mathias

    Retested it and a blank " " is not replaced by the default value; I must not have done a save when I tested this earlier. So it seems that this is the best solution to my problem. Users (me for one) skim modules quickly looking for specific values of this attribute and they are much easier to spot when the majority are blank rather than N/A.

    Thanks to both you and Louie for your help...

    Ken.