Book a Demo

Author Topic: Problem adding default for attribute  (Read 5158 times)

thomaskilian

  • Guest
Problem adding default for attribute
« on: May 11, 2007, 02:33:19 pm »
Help! It's probably simply too late, but since hours I try to add a default value for a new attribute. This is what I'm doing:
$class = $pk->Elements->AddNew ("newClass", "Class");
$class->Update();
$attr = $class->Attributes->AddNew ("newAttr", "int");
$attr->Default = "Default";
and that throws an exception saying that I'm not allowed to assign a value to $attr. Is is that something is wrong with the Perl interface or did I miss something?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Problem adding default for attribute
« Reply #1 on: May 12, 2007, 03:53:26 am »
A couple of Long shots here Thomas...

First, try calling $Attr.Update(); before trying to assign the default value.

Then...

My experience has been - regardless of what the documentation says - that whatever you provide in the Type field of AddNew becomes the data type of the Attribute (this behavior is different from most other EA collections). You've done this correctly.

However, since EA is aware of the Attribute data type, and since it is aware of the base type of the data, it might be evaluating what you provide. I wonder if you could assign a string to a different (i.e. not int) data type.

Please let me know what works.

David
No, you can't have it!

thomaskilian

  • Guest
Re: Problem adding default for attribute
« Reply #2 on: May 12, 2007, 07:20:04 am »
Hi David,
putting Update in front did not help (I guess I alread tried that a 1000 times last night).

The Addnew uses the 2nd parm as type. At last I put the default in the type and shoveled it manually  >:(

It seems I have to send a bug report. It's not possible to set anything once the attribute is created.

Thanks anyway  :)

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Problem adding default for attribute
« Reply #3 on: May 12, 2007, 10:34:25 am »
Mom always said there'd be those days...

Please let me know when this gets repaired. It could be a show stopper for me down the line a ways.

David
No, you can't have it!

thomaskilian

  • Guest
Re: Problem adding default for attribute
« Reply #4 on: May 14, 2007, 09:33:01 am »
I reported it to the support. I'll post the result here...

thomaskilian

  • Guest
Re: Problem adding default for attribute
« Reply #5 on: May 15, 2007, 11:11:40 pm »
Quote
Help! It's probably simply too late, but since hours I try to add a default value for a new attribute. This is what I'm doing:
$class = $pk->Elements->AddNew ("newClass", "Class");
$class->Update();
$attr = $class->Attributes->AddNew ("newAttr", "int");
$attr->Default = "Default";
and that throws an exception saying that I'm not allowed to assign a value to $attr. Is is that something is wrong with the Perl interface or did I miss something?

Sparx helped me out. Stupid me. Of course you have to write
$attr->{Default} = "Default";
I forgot the curly brackets when assigning a value to the attribute.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Problem adding default for attribute
« Reply #6 on: May 16, 2007, 01:25:56 am »
Yep, jest one a them days...
No, you can't have it!