This site has been archived. Please visit help.fulcrumapp.com for our new support documentation and contact information.

Force webhooks to run for inserting existing records

srweal's Avatar

srweal

11 Nov, 2015 11:16 PM

Hi,

We've just set up webhooks and a handler to write this into a MSSQL database. Works well. However, our client has existing records that need to come across. Is there a simple way to 'replay' the history for each record and thus write them across to our target database.

Or will it be necessary to export/import this data separately? Please give any advice on how best to achieve this. Thanks.

Steve

  1. 1 Posted by Bryan McBride on 12 Nov, 2015 02:40 PM

    Bryan McBride's Avatar

    Hi Steve,

    It really depends on how many existing Fulcrum records you need to get into your MSSQL database. If there are tons of records, you are probably better off exporting out of Fulcrum, or using data shares with query parameters to grab the records you need and importing them directly into your database.

    If you are only talking about a handful of records (several hundred?), you could write an API script to loop through the records and force an update to trigger the webhook notifications. Here's an example using the fulcrum-python library:

    from fulcrum import Fulcrum
    
    api_key = 'my-api-key'
    form_id = 'my-form-id'
    fulcrum = Fulcrum(key=api_key)
    
    records = fulcrum.records.search(url_params={'form_id': form_id})
    
    for record in records['records']:
        data = fulcrum.records.find(record['id'])
        record = fulcrum.records.update(record['id'], data)
    

    Beware though, that this has the potential to hammer your webhook script and you may hit the API limit of 5,000 calls an hour per user.

  2. 2 Posted by srweal on 12 Nov, 2015 09:19 PM

    srweal's Avatar

    Thanks. That is exactly the kind of insight I was after. Think I'll just
    import from an export.

    I presume that if my target database doesn't contain the record already,
    then triggering the webhook will still send a record.update payload that I
    need to INSERT (instead of UPDATE).

    Ta.

  3. 3 Posted by Bryan McBride on 12 Nov, 2015 09:26 PM

    Bryan McBride's Avatar

    That is correct. If the record exists in Fulcrum, the webhook event type will be record.update, so you may have to do some logic on your end to see if the record exists or not in your db. I typically wait until off hours when no one is syncing, run an export out of Fulcrum, then import that into my database so I know everything matches 1 to 1. Once they are mirrored in Fulcrum and your database, your webhooks should function fine on their own.

  4. Bryan McBride closed this discussion on 12 Nov, 2015 09:26 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac