5 Replies Latest reply on Jun 21, 2018 3:29 PM by John Neighbors

    how can i grab pro-grammatically the last viewed contact?

    Apprentice

      how can i grab the most recent viewed contact on goldmine programatically?

        • 1. Re: how can i grab pro-grammatically the last viewed contact?
          John Neighbors SSMMVPGroup

          Not sure if this will help or not?!?!

           

          This information is stored in the HISTORY_ITEM table.  USERID equals the GoldMine user. TYPE_CODE = 1 for CONTACT1 records.

           

          This SQL query will identify the most recent record you are looking for (GM user JOHN as an example):

           

              select top 1 contact, company, accountno from contact1

                  inner join history_item on (history_item.frecid = contact1.recid)

                  where history_item.userid = 'JOHN' and history_item.type_code = 1

                  order by history_item.view_date desc

           

          This SQL query will identify the LIST of "recently viewed" items, like shows in the GoldMine interface, to the left of the contact record:

           

              select contact, company, accountno from contact1

                  inner join history_item on (history_item.frecid = contact1.recid)

                  where history_item.userid = 'JOHN' and history_item.type_code = 1

                  order by history_item.view_date desc

           

          Not sure what you're using "programmatically", but that's how you'd get to the data via custom SQL coding.

           

          Hope this feedback helps.

          • 2. Re: how can i grab pro-grammatically the last viewed contact?
            Apprentice

            that should answer my question. thank you so much. i will give it a try

            • 3. Re: how can i grab pro-grammatically the last viewed contact?
              Apprentice

              it worked. thank you very much

              • 4. Re: how can i grab pro-grammatically the last viewed contact?
                Apprentice

                Hi John,

                 

                The query works, but I had to provide the userId. I am using GMXMLAPI to build a custom form that is launched from Goldmine Interface menu.

                When the user searches for a contact, that form should be able to get the most recently viewed contact by that user.

                 

                Is there any way to know who is the user who is currently using Goldmine Interface (thus searching contact).

                I have asked this question, and I didn't get any response.

                 

                Thank you

                • 5. Re: how can i grab pro-grammatically the last viewed contact?
                  John Neighbors SSMMVPGroup

                  As I said before, I am not sure what you're using "programmatically", but...

                   

                  The only way I know to do this at the SQL-level (AKA not using traditional API calls) requires that each user have a distinct SQL login ID setup and associated with their GoldMine ID.  This is easy to do and setup, but most GoldMine implementations do NOT have distinct SQL login IDs setup per user, but rather, have everyone using GoldMine using the same SQL login ID.

                   

                  For clients that I've setup similar functionality, it usually boils down to a handful of users that the custom piece I am setting up is related to (vs. being applicable to ALL GoldMine users).  In those cases, we simply setup distinct SQL login IDs for those specific users, and everyone else shares the SAME SQL login.  Within my SQL coding, I then determine if it's a user I care about or one that I don't, based on the SQL login.

                   

                  Presuming they are setup with distinct SQL login IDs, per user, then I simply use the SQL SYSTEM_USER feature to identify the SQL LOGIN ID of the current GM user/session:

                   

                  https://docs.microsoft.com/en-us/sql/t-sql/functions/system-user-transact-sql?view=sql-server-2017

                   

                  It works great and is easy to use.

                   

                  A simple query to run via GM's SQL query tab, if you want to research: 

                   

                  SELECT @@SPID AS 'ID', SYSTEM_USER AS 'Login Name', USER AS 'User Name', SESSION_USER as 'SESSION_USER', CURRENT_USER as 'CURRENT_USER', USER_NAME() as 'USER_NAME()'

                   

                  I'm only talking about the SYSTEM_USER piece, not all the others.

                   

                  I'm sure there is a more "textbook" way of doing this via API calls, but, purely VIA SQL, this is the best way I know.

                   

                  Hope this feedback helps.