7 Replies Latest reply on Apr 26, 2017 1:42 PM by Pablo Fernández

    create a notification in an addin

    Pablo Fernández

      Hi,

      Is it possible to programatically (in an addin) create a notification for an user when a certain file has been checked out?

      I could not find any interfaces to add automatic notifications.

       

      Regards

        • Re: create a notification in an addin
          Jeff Sweeney

          Sure!

           

          Add-ins can watch for a check-out event.

           

          You can manually watch for a check-out event out of the box. Highlight a file/folder you want to watch, RMB click, Notify, Me when checked out.

          Checkout.JPG

            • Re: create a notification in an addin
              Pablo Fernández

              Hi Jeff,

               

              I know that each user can do that manually, but what I want to do is to create that notification for the user automatically in an addin

                • Re: create a notification in an addin
                  Jeff Sweeney

                  Certainly possible!

                  You'll want to watch for either the PostLock or PreLock event. (Back in the old days, they used the term "Lock" instead of "Checkout".)

                    • Re: create a notification in an addin
                      Pablo Fernández

                      But what api interfaces do I use to add a notification? Or do I have to modify the sql tables myself?

                      What I want to do is to create a notification for a particular user, like what the user does when he selects the menu option you showed

                        • Re: create a notification in an addin
                          Steven Dod

                          I have set up several of these types of notifications but they are based on a checkbox or username in a data card.  Below is a snippit of how I do it but it goes to all users in a group.  You should be able to modify to fit your needs.

                           

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

                                       'Declare and build the string so a hyperlink can be emailed to the Admin Group
                                  Const exploreHTMLString = "<a href=""conisio://{0}/explore?projectid={1}&documentid={2}&objecttype=1"">{3}</a>"

                                       'Declare and set the vault to the calling vault where the file is being added.
                                  Dim vault As EdmVault5
                                  vault = poCmd.mpoVault

                                       'Set the file ID, folder ID, and the filename to variables so the hyperlink can be built
                                  Dim folderID As Integer = ppoData(0).mlObjectID2
                                  Dim fileId As Integer = ppoData(0).mlObjectID1

                                       'Get the filename from the path string to use for the hyperlink text
                                  Dim r As Integer = InStrRev(ppoData(0).mbsStrData1, "\")
                                  Dim l As Integer = Len(ppoData(0).mbsStrData1)
                                  Dim fName = Right(ppoData(0).mbsStrData1, l - r)

                                       'Declare and set the variable to the Destination state ID
                                  Dim stateID As Integer = ppoData(0).mlLongData2
                                  Dim stateName As String = ppoData(0).mbsStrData2

                                       'Check to see if the file is an EC file (EC XXXXXX.xlsm) & is going to EPR processing (ID 67)
                                  Dim pos As Integer = InStr(fName, "EC ")
                                  If (pos > 0) And stateID = 67 Then
                                           'Create the hyperlink for the file that was just added so it can be sent to the MFG group in a message.
                                      Dim explorelink = String.Format(exploreHTMLString, vault.Name, folderID.ToString, fileId.ToString, fName)
                                           'Build the message body text
                                      Dim message = "(put your message here) <br/> <br/>" + explorelink
                                           'Call the SendMessage sub with the correct variables
                                      SendMessage(vault, "MFG Engineering", message)
                                  End If

                              End Sub

                           

                              Private Sub SendMessage(ByVal vault As EdmVault5, ByVal groupName As String, ByVal msgBody As String)

                                  Dim userMgr As IEdmUserMgr5
                                  userMgr = vault
                                  Dim group As IEdmUserGroup5
                                  group = userMgr.GetUserGroup(groupName)
                                  Dim pos As IEdmPos5
                                  pos = group.GetFirstUserPosition

                                  While Not pos.IsNull
                                      Dim user As IEdmUser5
                                      user = group.GetNextUser(pos)
                                      user.SendMsg("(put subject text here)", msgBody)
                                  End While

                              End Sub

                          • Re: create a notification in an addin
                            Jeff Sweeney

                            You'll need to create an add-in. There is a nice "tutorial" for creating them in the PDM API help file.

                            I wouldn't recommend using the SQL tables for this project.