14 Replies Latest reply on Jul 9, 2014 10:33 AM by Brian Dalton

    Can I Hook a Transition Before the Dialog?

    Brian Dalton

      I just managed to create an addin (with considerable help from the forum ) that hooks a transition before the state change, but I still have a 'Do Transition' dialog popping up before the hook sets in.


      Is there any way to get the hook to grab control before the dialog box appears?  Or maybe a setting that stops the dialog altogether?  Not a crucial concern, just a matter of convenience.

        • Re: Can I Hook a Transition Before the Dialog?
          Tim Webb

          'Call me before a file has changed state



          That will hook the transition before the file changes state but I don't think you can hook the transition before the transition action dialog is displayed.


          Maybe someone else knows differently.


          Hope that helps.

          • Re: Can I Hook a Transition Before the Dialog?
            Lee CS Young

            It's possible to set mbCancel to true to prevent an event/command. It's part of the EdmCmd struct that is passed in the OnCmd method. You probably don't need this though. What are you trying to achieve?

              • Re: Can I Hook a Transition Before the Dialog?
                Brian Dalton

                What I'm looking to do is to essentially take over the transition process (in certain situations) to ensure that only the right files make the transition according to our particular business processes.


                We often want to send file A through a transition and have it carry files B, C and D with it when it goes.  The relationship that determines which files will go along with file A is determined by our own process.  My original strategy was to create user-defined references from file A to B, C and D and allow EPDM to carry all referenced files through transitions along with the selected file.


                The problem with this method is that EPDM doesn't distinguish between references created for our internal purposes and those created by SW, for instance the references an assembly has to its components.  As a result, when sending file A through a transition, EPDM wants to also send every referenced file all the way down the tree, regardless of how that reference was created.


                Example:  File A is an Excel document, file B is a SW part, file C is a SW part and file D is a SW assembly.  When a user sends file A through a transition, she wants A, B, C and D to go together, but since D has further references (it's an assembly), she also gets many other files that are referenced by D, which should not be included.


                EPDM provides the 'opportunity' to deal with this problem by showing a dialog box listing all of the files in the entire reference tree and with check marks next to those which it thinks should be included in the transition.  The user is expected to look through the list and uncheck any file that they don't want to have included.  It's technically a functional solution, but...


                In fact it is a royal PITA and my users complain endlessly and bitterly about it.  It's made worse by the ham-fisted way in which EPDM creates the reference list, including pointless entries of virtual parts (they confuse the users and you can't de-select them, so why are they there?) and multiple listings of the same parts over and over, owing to the fact that some parts are referenced more than once.  Multiple configurations creates even more pointless, tedious and confusing duplication.


                In reality what often happens is that the user just accepts whatever EPDM wants, or they don't take the time to look carefully through the list, so many files are sent through transitions by error, and I get to somehow find them, and fix them, one at a time, by rolling them back.  A fragile, annoying, error-prone and inefficient situation that I need to fix, ASAP.


                My idea is to hook transitions (prestate) and use our own logic to determine which files should go along with the selected file.  Then I could handle the transitions through code rather than allowing EPDM to use the blanket rule of any reference goes.  I could create a dialog that allows the user to see what files will be included if that's of value, but there's really no value in allowing the standard EPDM 'Do Transition' dialog to show if there's only one file listed or if the contents do not reflect which files will actually be included in the transition.


                I would like to:

                • hook the transition
                • determine if it needs to be controlled through code
                • if it doesn't, allow EPDM to handle it in the normal way
                • if it does, cancel EPDM's handling of the process and do it myself, hopefully without showing the EPDM dialog


                So, I could do all this (not sure how to cancel EPDM's handling) except for stopping the dialog from showing.

                  • Re: Can I Hook a Transition Before the Dialog?
                    Greg Rupp

                    Have you consider enabling "Do not mark referenced files when changing state " in the user or group Settings? This will eliminate your PITA moment of having Every file checked in the dialog box and only mark the file that is selected.

                    Reference Dialog.jpg

                      • Re: Can I Hook a Transition Before the Dialog?
                        Brian Dalton

                        I plan to do that once I have the ability to take control of the transition process.  For now, it's necessary in order to have linked files transition together.


                        My main issues right now are how to disable the dialog from showing unless I want it to, and how to cancel the EPDM transition so I can control it myself.

                          • Re: Can I Hook a Transition Before the Dialog?
                            Greg Rupp

                            Maybe instead of using a built in transaction, you can create your own task/menu item that is a transistion using the IEdmBatchChangeState command. I never used it, but I know it has the option of not displaying the Dialog box.


                            As for canceling a transaction, Lee is correct, in that you can set the mbCancel value to cancel the transaction all together.





                            public void OnCmd(ref EdmCmd edmCmd, ref Array data)




                                 if (something)



                                   edmCmd.mbCancel = true;







                              • Re: Can I Hook a Transition Before the Dialog?
                                Tim Webb

                                Lee and Greg, thanks for the code. Greg, thanks for the c# code. Since I'm a vb'er, I tried the equivalent in vb.net and the code works but the transition box is still displayed.


                                I also realized I had the hook set for a poststate so I changed the hook to PreState and did the same in the OnCmd. Code blocks the transition but after the transition box is displayed. hope that clarifies it.


                                Public Sub OnCmd(ByRef poCmd As EdmLib.EdmCmd, ByRef ppoData As System.Array) Implements EdmLib.IEdmAddIn5.OnCmd

                                If poCmd.meCmdType = EdmCmdType.EdmCmd_PreState Then

                                          'Cancel the add-in action if this is a transition

                                          poCmd.mbCancel = True 'or whatever...

                                End If

                                End Sub


                        • Re: Can I Hook a Transition Before the Dialog?
                          Tim Webb

                          Thanks for the insight Lee.

                        • Re: Can I Hook a Transition Before the Dialog?
                          Jim Sculley

                          The only way to do this is to add a menu command (IEdmCmdMgr5::AddCmd) for whatever you are trying to do, and then do the state change yourself via code via the IEdmBatchChangeState object.  For example, if you wanted to make a single click method for moving one or more files from State A to State B without showing a dialog.


                          As Lee said though, you probably don't want to do this.  The State Change dialog is your last chance for users to notice any problems with the files being transitioned.


                          Jim S.

                          • Re: Can I Hook a Transition Before the Dialog?
                            Jeremy Schmidt



                            I feel your pain. We have a very similar scenario here in which we attach other files. Also, my users have the same complaints about the dialog. In any case, I was able to work around this situation by cancelling the initial dialog and creating my own. So basically, the default tree shows up, the user unchecks or adds whatever files they want, the user clicks ok, then a second tree shows up with all of the additional files. It's not a great solution, and it's annoying that the tree has to pop up twice, but it at least works. The real annoyance, is that I couldn't find a way to collect the options the user selected from the first tree. For example, if they choose to keep the file checked out in the first tree, it defaults back to a regular check in on the second tree. The first tree is only useful in determining which files to include.


                            I realize this isn't exactly what you want, but hopefully it helps. I'd also be interested if there is a better way. I don't want to create it off a menu item, because I use this for check in, check out, and state changes, and I don't want to modify how these actions are enacted.

                            • Re: Can I Hook a Transition Before the Dialog?
                              Bogic Dubak

                              Is it an option for you to assign a different workflow for all the files of a certain type which you don't want to be transitioned?


                              In that way you would avoid users sending those files to another workflow state by setting up a condition to block unwanted action.