Author Topic: Change element status after user change any element attribute  (Read 7299 times)

etaha

  • EA User
  • **
  • Posts: 47
  • Karma: +1/-1
    • View Profile
Change element status after user change any element attribute
« on: January 30, 2018, 09:05:54 am »
Is there a way/event to change status of an element after user change any attribute of an element?
For example, if element status is approved I need to revert it back proposed in case user change element name/description/tagvalue etc..
Thanks in Advance.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Change element status after user change any element attribute
« Reply #1 on: January 30, 2018, 09:50:14 am »
You need to write an add-in for that (or use Geert Bellekens' EA-Matic). There's a broadcast event which tells you that an element has changes and you can do further action.

q.

etaha

  • EA User
  • **
  • Posts: 47
  • Karma: +1/-1
    • View Profile
Re: Change element status after user change any element attribute
« Reply #2 on: January 30, 2018, 07:01:17 pm »
Thanks a lot.
I've checked all broadcast events documentation amd EA-Matics available events; but I couldn't figure out which event to use.
There are events for pre-posting/deleting element but none for modify element.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Change element status after user change any element attribute
« Reply #3 on: January 30, 2018, 07:17:17 pm »
Hello,

You're looking for EA_OnNotifyContextItemModified. It's in with the other context item events.

Note, however, that semantically this approach will only ever give you a partial solution. It doesn't cover all cases where something is changed which affects en element (eg inherited attributes).


/Uffe
My theories are always correct, just apply them to the right reality.

etaha

  • EA User
  • **
  • Posts: 47
  • Karma: +1/-1
    • View Profile
Re: Change element status after user change any element attribute
« Reply #4 on: January 30, 2018, 07:21:12 pm »
I'll check that event; It's wierd that it's under contextmenu.
Thanks you all.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Change element status after user change any element attribute
« Reply #5 on: January 30, 2018, 07:43:19 pm »
Hehe. EA is not only unique in its user interface but also in its documentation.  The people from planet Sparx have a different mindset than us common earthlings.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Change element status after user change any element attribute
« Reply #6 on: January 30, 2018, 10:19:09 pm »
I'll check that event; It's wierd that it's under contextmenu.
It's not context menu -- it's context item.

The context item events tell you when the user has changed the selection in the GUI, double-clicked something or made changes to the currently selected thing (element, diagram, etc).

So they're GUI-related, but nothing to do with any menus.

/U
My theories are always correct, just apply them to the right reality.

etaha

  • EA User
  • **
  • Posts: 47
  • Karma: +1/-1
    • View Profile
Re: Change element status after user change any element attribute
« Reply #7 on: January 31, 2018, 07:37:16 am »
Thanks for the note..and sorry I didn't notice it..

I've register that event with EA-Matic and it works, but there is an issue when user wants to change to Approve this will automatically revert to Proposed
Code: [Select]
function EA_OnNotifyContextItemModified(GUID, ot)
Dim el
If ot = EA.ObjectType.otRequirement then
    Set el = Repository.GetElementByGuid(GUID)
if el.Status = "Approved" then
el.Status = "Proposed"
el.Update()
end if
end if
end function
Is there a way to know the updated attributes of the element?
Thanks a lot.

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Change element status after user change any element attribute
« Reply #8 on: January 31, 2018, 02:52:12 pm »
By default there is no method says which are the attributes got updated. You have to do a compare, then update . EA_OnNotifyContextItemModified will be triggered when current context item has been modified
« Last Edit: January 31, 2018, 04:37:06 pm by Nabil »
Nabil

etaha

  • EA User
  • **
  • Posts: 47
  • Karma: +1/-1
    • View Profile
Re: Change element status after user change any element attribute
« Reply #9 on: January 31, 2018, 03:12:20 pm »
Thanks for the reply..
As per my tests, this event is not triggered unless user clicks on Apply or Ok buttons, which is after the changes happened and no way to get element attributes' values before updated by this event only.
Any ideas?
Thanks in Advance...

Nabil

  • EA User
  • **
  • Posts: 147
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Change element status after user change any element attribute
« Reply #10 on: January 31, 2018, 04:36:16 pm »
You have to get the previous values in session for a compare. When the user clicks next element/connector/diagram EA_OnContextItemChanged event will get triggered.
Nabil

etaha

  • EA User
  • **
  • Posts: 47
  • Karma: +1/-1
    • View Profile
Re: Change element status after user change any element attribute
« Reply #11 on: January 31, 2018, 06:16:26 pm »
Many thanks.. I'll try it out.

etaha

  • EA User
  • **
  • Posts: 47
  • Karma: +1/-1
    • View Profile
Re: Change element status after user change any element attribute
« Reply #12 on: February 01, 2018, 01:34:26 am »
Appreciated. Many thanks to all. It works.