Book a Demo

Author Topic: Partitioning an Activity via API  (Read 4326 times)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Partitioning an Activity via API
« on: August 21, 2014, 11:10:09 pm »
One of my readers got stuck with my example about partitioning an activity. The code I presented
Code: [Select]
1 part = activity.Partitions.AddNew ("p1", "");
2 part.Size = "90";
3 part.Update ();
4 part = activity.Partitions.AddNew ("p2", "");
5 part.Size = "90";
6 part.Update ();
7 activity.Partitions.Refresh ();
Does not work (he seems to be the first one to get that far ;))
Now actually there seems to be a buggy behavior Since when you call the Refresh this will annihilate the addition. Instead (since this is one of those inconsistencies in EA) this is a semi-diagram operation: you should call a Repository.SaveDiagram(id) finally. So the Activity/State must be present on the open diagram. Else this method will not work. :-X

Book update is on the way.

q.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Partitioning an Activity via API
« Reply #1 on: August 22, 2014, 10:45:57 am »
The Partition object does not have an Update() method.  You add items to this collection and then call Element.Update() to commit the changes.

Code: [Select]
part = activity.Partitions.AddNew("partition1", "");
part.Size = "90";
part = activity.Partitions.AddNew("partition2", "");
part.Size = "90";
activity.Update();

Repository.SaveDiagram() is intended for committing any unsaved changes currently in the GUI.  Generally not a good idea to call this method after making other changes via automation as it will probably just undo your changes.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Partitioning an Activity via API
« Reply #2 on: August 22, 2014, 03:41:29 pm »
Well, I could again start arguing about consistency regarding the behavior of the Partitions collection ::) But I guess a Thank You is more appropriate :)

q.