Detect when table gets updated

Hello,

We currently have Windows services (written in C#, .NET) that push data out from some Sage tables to a custom API, which then stores it in a private SQL Server Database. Depending on the service, it might trigger every minute, every 5 minutes, or once every day.

We are looking for a real-time end result since the current implementation presents delays in synchronizing data.

Is there a way to trigger our code somehow when data in a specific table gets added, updated, or deleted?

Cheers,
Imad

Parents
  • 0

    What tables are you talking about?  Most tables have these two fields.  You can read these fields to know if updated.

    105  DateUpdated . . . . . . . . .     8 SNN  Last Update Date. . . . . . . .DATE
                                                    Read Only:Y Notes: YYYYMMDD
     106  TimeUpdated . . . . . . . . .     8 SNN  Last Update Time. . . . . . . .TIME
                                                    Read Only:Y
  • 0 in reply to BigLouie

    That's what I do today, but I have to keep reading these fields every minute. Or change the service to read every X seconds, which might be heavy on the database, no?

  • 0 in reply to Imad Maks

    You would need to keep a Sage 100 session open (using a license) so that you could use User Defined Scripts and business object events to trigger your service when they trigger on table and/or field writes.

  • 0 in reply to connex

    I'll look into that, thanks!

  • 0 in reply to connex

    I created a new user-defined script that triggers on Post-Write to the CI_Item table.

    The goal of this script is to send an HTTP request to an API to notify it that the item has been updated/added.

    This is the script:

     

    itemCode = ""
    retVal = oBusObj.GetValue("ItemCode$", itemCode)
    url = https://someUrl/ & itemCode & ""
    
    Set o = CreateObject("MSXML2.XMLHTTP")
    o.open "GET", url , False
    o.send
    
    response = o.responseText

     

    When I open item maintenance and edit the description for an item (000001, for instance), my API receives the request successfully. Without closing the item maintenance window, no API call is made if I edit the same item again. Still, the script works fine without closing the window if I try editing another item.

    Now, if I close the window and open it again, and I edit the item 000001, the script triggers the API call.

    It seems like the script is re-loaded for the item when I re-open the window. However, if I keep the window open, the script is not triggered again.

    Any thought?

  • 0 in reply to Imad Maks

    You will get one Table Post-Write per "Accept"-ance. I suggest you learn how to use trace and oScript.DebugPrint to monitor your script executions.

Reply Children