Trigger to show dialog box while closing a module

Hi All,

Can anyone help with following request

Requirement:

To add a feature which enforces, if the user did NOT fill in a field, they would not be able to close out their edit session, or possibly just get a warning.
This would be nice at the object level, rather than the module level.

Action Plan :
I am not sure how to do it in object level, so i tried to do it in module level.
1.If a user has left a specfic field in a object as empty i want to show a warning box whenever the user is closing the module.
2.The warning box should have buttons as "Confrim" and "Cancel".
3.If the user clicks on "confrim" the module should get closed and if the user clicks on "cancel" button the module should be kept open for further action by user.
To achive this i have tried as following :
1.I have created a trigger which is called when a user is trying to close a module.
2.The triggers checks the attribute value for all objects and if there are more than 1 object without any value for the attribute then it shows the dialog box.
3.If the user clicks on "confirm" then i am calling the close function.
4.If the user clicks on "cancel" i should canecl the prvious close operation which was called before firing the trigger.and the module should be kept open for further modification.

Can anyone please help me to achieve the functionality of "cancel" button.
asunilkumar - Fri May 25 10:24:53 EDT 2012

Re: Trigger to show dialog box while closing a module
llandale - Fri May 25 15:41:07 EDT 2012

Triggers type "post" occur after the event and there is no mechanism for preventing the event. Triggers type "pre" provide the mechanism for preventing the event; in this case closing the module. "pre" triggers allow you to "set" the trigger status, which instructs DOORS to allow or prevent the event. The status can be set and changed inside the trigger, it only applies when the trigger code ends. The event is disallowed if ANY "pre" trigger prevents it.

My "pre" triggers routinely do this:
  • "set(trigPreConPass)"
    • every time at the start. Subsequent suitablility checks which "halt" the trigger will therefore allow the event.
    • I think "pass" is the default setting; but I will always set it explicitely.
  • "set(trigPreConFail)"
    • carefully inside the trigger once all the desired criteria for prevention occurs (in your case cancel).

pre-close-module triggers can easily have a bug preventing closing completely, requiring aborting the DOORS.exe process and may leave locks in the database. Code them very cafefully.

As for your actual problem: I believe there is no perfect solution and am sure there is no elegant solution. I believe you will need to prevent errors as best you can and live with that; having some background program that looks for these null values. The user can save the module and then downgrade it to read, and THEN close the module; which would make your checking OBE. I think I would have some form of pre-obj-sync trigger as well as a pre-module-close trigger to protect yourself as best you can.

-Louie

I don't know what statuses "trigRunOK" and "trigError" are for.

Re: Trigger to show dialog box while closing a module
asunilkumar - Tue May 29 06:05:11 EDT 2012

llandale - Fri May 25 15:41:07 EDT 2012
Triggers type "post" occur after the event and there is no mechanism for preventing the event. Triggers type "pre" provide the mechanism for preventing the event; in this case closing the module. "pre" triggers allow you to "set" the trigger status, which instructs DOORS to allow or prevent the event. The status can be set and changed inside the trigger, it only applies when the trigger code ends. The event is disallowed if ANY "pre" trigger prevents it.

My "pre" triggers routinely do this:

  • "set(trigPreConPass)"
    • every time at the start. Subsequent suitablility checks which "halt" the trigger will therefore allow the event.
    • I think "pass" is the default setting; but I will always set it explicitely.
  • "set(trigPreConFail)"
    • carefully inside the trigger once all the desired criteria for prevention occurs (in your case cancel).

pre-close-module triggers can easily have a bug preventing closing completely, requiring aborting the DOORS.exe process and may leave locks in the database. Code them very cafefully.

As for your actual problem: I believe there is no perfect solution and am sure there is no elegant solution. I believe you will need to prevent errors as best you can and live with that; having some background program that looks for these null values. The user can save the module and then downgrade it to read, and THEN close the module; which would make your checking OBE. I think I would have some form of pre-obj-sync trigger as well as a pre-module-close trigger to protect yourself as best you can.

-Louie

I don't know what statuses "trigRunOK" and "trigError" are for.

Thanks a lot Louie. This one is working. I am not sure about the locks, i haven't seen the errors yet.
I will try to code care fully to avoid locks .

Thanks again for letting me know the pros and crons