13 Replies Latest reply on Nov 15, 2012 8:41 PM by Tim Webb

    Wouldn't it be nice if we could......

    Jim Sculley

      execute an addin method as an action in a transition?

       

      I want to pop up a form at a transition and it seems that I have 3 options:

       

      A.  Use the 'Execute Task' action with an add-in that uses a template card.  This is the most straightforward and the least customizable.  For instance, say I have a text box for which I want to let the user know how many characters they have left to use in a length limited description.  I don't think I can do that with a template card.

       

      B.  Use the 'Execute Task' action with an add-in that has a custom user form.  This allows me to put whatever bells and whistles I want on the form.  The problem is that tasks are inherently slow to execute, simply because they are asynchronous.  The long pause between the time the transition is initiated and the time the form pops up will annoy the users.  Same would apply for option A above.

       

      C.  Use the 'Execute Command' action to run a separate program that pops up a custom form.  This is customizable and more synchronous than a task.  Great.  Seems to address the problems with options A abd B.   The downside is that this is now an external process that isn't privvy to the file(s) involved in the transition, unlike an add-in where that information is passed in to the OnCmd method.

       

      I would like to see a new transition action (Call Add-in Method) that allows you to specify an add-in name and a method name from the add-in to execute.  The parameters to this method would include all the relevant transition data (similar to OnCmd) so that the code could do whatever work is necessary.

       

      Give me this and there is nothing that I cannot do.

       

      Jim S.

        • Re: Wouldn't it be nice if we could......

          You can do this. Check for the command type that your add-in is monitoring.

           

          In your GetAddInInfo Sub add

           

                  ' Call me after a file has changed states
                  poCmdMgr.AddHook(EdmCmdType.EdmCmd_PostState)

           

                  ' Call me before a file has changed states
                  poCmdMgr.AddHook(EdmCmdType.EdmCmd_PreState)

           

          And then add code in your OnCmd Sub

           

          If poCmd.meCmdType = EdmCmdType.EdmCmd_PostState Then - after a state change

           

          If poCmd.meCmdType = EdmCmdType.EdmCmd_PostState  Then - before a state change

           

          I did this for creating pdfs of drawings when they were approved before we had Tasks.

            • Re: Wouldn't it be nice if we could......
              Jim Sculley

              Excellent.  Thanks for the info.

               

              Jim S.

              • Re: Wouldn't it be nice if we could......
                Brian Dalton

                So, when using this technique, do you activate the addin using "Execute Task", or "Execute Command".

                 

                If it's "Execute Task", does the addin need to be created in a special 'Task' way, or will any old addin DLL work?

                 

                Sorry, Me.Noob = True

                  • Re: Wouldn't it be nice if we could......
                    Jim Sculley

                    Neither.  The add-in itself is *watching* for state changes and takes action as necessary.  Nothing is done via the transitino actions.

                     

                    Jim S.

                      • Re: Wouldn't it be nice if we could......
                        Brian Dalton

                        Hmmm, what if I only want it to be triggered by specific transitions, not all of them?

                          • Re: Wouldn't it be nice if we could......
                            Lee CS Young

                            You know the transition from the EdmCmdData struct; the transition ID, the source state ID, and the destination state ID. (EdmCmd_PreState and PostState). Check to see if it's the right transition and go from there.

                             

                            Edit: As a side note, I think EPDM API should have it's own forum.

                              • Re: Wouldn't it be nice if we could......
                                Tim Webb

                                Edit: As a side note, I think EPDM API should have it's own forum.

                                 

                                I agree

                                • Re: Wouldn't it be nice if we could......
                                  Brian Dalton

                                  OK... so I wouldn't be writing a 'task addin', but instead a regular addin?  Where do I look to find a EdmCmdData struct, or the definition of such a daunting creature?

                                   

                                  Sorry, I have never done this before.  All I have to go on is what's in the PDM Programmer's Reference Guide.  It has an example of a standalone app, an addin and a task addin.

                                   

                                  I've done a little VBA programming so I can do some things in the API itself (checkin/out, variables, etc.) but all the overhead for actual addins is new and confusing for me.  Unfortunately our CEO wants the system to dance to any tune he calls, but he won't pay for programming work or for a training course for me.  I'm at the mercy of whatever I can glean off the web...

                                    • Re: Wouldn't it be nice if we could......
                                      Tim Webb

                                      Hi Brian / Jim,

                                       

                                      Not answering for Lee or Wayne but you actually have two options:

                                       

                                      1. Dispatch can post a simple listbox for a selection to be made and you can cancel the transition if you don't get the proper response
                                      2. Write a simple addin (not a task addin) with a brief tutorial or commented code.

                                       

                                      Tim

                                      • Re: Wouldn't it be nice if we could......
                                        Lee CS Young

                                        Brian Dalton wrote:

                                         

                                        OK... so I wouldn't be writing a 'task addin', but instead a regular addin?  Where do I look to find a EdmCmdData struct, or the definition of such a daunting creature?

                                         

                                        Sorry, I have never done this before.  All I have to go on is what's in the PDM Programmer's Reference Guide.  It has an example of a standalone app, an addin and a task addin.

                                         

                                        I've done a little VBA programming so I can do some things in the API itself (checkin/out, variables, etc.) but all the overhead for actual addins is new and confusing for me.  Unfortunately our CEO wants the system to dance to any tune he calls, but he won't pay for programming work or for a training course for me.  I'm at the mercy of whatever I can glean off the web...

                                         

                                        You'd write a regular addin or use Dispatch. I have limited knowledge of Dispatch because I tend to do everything with addins. Dispatch works fine - just a preference of mine and at times it's overkill to use an addin.

                                         

                                        The programmer's guide is where the information is. If you lookup EdmCmdData in the guide you'll see that all the structs are listed. The explanation given in the guide for EdmCmdData should help you understand what it's for and how it's used. Basically you're given a record of each file included in the event.

                                         

                                        Once you've created your first addin you'll probably find that it's not that daunting. If you have any questions or need a hand, post here or send me a private message. I am more than willing to help where I can. I won't write code for you (that's what consulting is for) but I'll try to point you in the right direction.