Sparx Systems Forum

Discussion => General Board => Topic started by: tzafrir on December 07, 2017, 05:13:10 pm

Title: Update a state of an element
Post by: tzafrir on December 07, 2017, 05:13:10 pm
Hi,

I want to update a state of an element with some value.
I did not find any attribute on the element that holds that can be set.

I tried to use the query:
update t_object set StateFlags = 'SomeStateValue' where object_id = ElementID
and then:
repository.Execute(sql);
element.Update();

This did not update it as well.

Does someone know how can it be updated?

Thanks.
Title: Re: Update a state of an element
Post by: Geert Bellekens on December 07, 2017, 06:13:19 pm
What do you mean by "State" of an element?

Geert
Title: Re: Update a state of an element
Post by: qwerty on December 07, 2017, 08:05:14 pm
Basically your assumption is correct. Did you a) reload the diagram and b) verify with a query that the UPDATE succeeded?

q.
Title: Re: Update a state of an element
Post by: Geert Bellekens on December 07, 2017, 08:32:26 pm
I think in fact that your element.update() will undo the changes you did directly to the database.

Geert
Title: Re: Update a state of an element
Post by: qwerty on December 07, 2017, 09:34:48 pm
Of course. Mixing API and direct database is the best way to shoot yourself in the knee.

q.
Title: Re: Update a state of an element
Post by: tzafrir on December 10, 2017, 06:00:22 pm
Thanks,
The issue was with the element.Update() it deleted the value.

You are right,
mixing is problematic but the problem is that there is no element attribute to StateFlags column.