Jump to content

Recommended Posts

Hi, 
 
 We are using the Web hooks to enable us to automatically add/update assets into hornbill and are having issue with the way they work.
 
When creating an asset, you receive two web hook calls. First, you get an "asset create" call which contains all of the properties of the asset but not the Hornbill primary key. You then get an "asset update" call which simply contains the Hornbill primary key and no other properties. This makes it difficult to work out which asset the primary key actually applies to. Can one of the following modifications be made to the process to make it easier please?
1) Include the primary key on the "asset create" web hook call.
2) Include the asset name (h_name) on the "asset update" when the primary key is added to the record.
 
Thanks
Francis 
Link to comment
Share on other sites

Hi @Francis von Stein,

There are 2 events around entity record creation, when we're talking webhooks: 

  • Create : This event is fired before the record is added to the entity, so its payload only contains the user-provided values and NOT any auto-assigned values (including auto-incrementing primary keys);
  • Created  This event is fired after the record is added to the entity, and its payload contains all user provided AND auto-assigned values (including primary keys).

    For example, this is an example of the Create payload:

    {
    	"onEntityEvent": {
    		"eventSource": "urn:webhook:entity:Asset:create",
    		"callingSessionId": "U2020072800159591",
    		"eventTime": "2020-07-28 08:56:36Z",
    		"actionBy": "steveg",
    		"actionByName": "Steve Goldthorpe",
    		"entity": "Asset",
    		"record": {
    			"h_acq_method": "-1",
    			"h_class": "computer",
    			"h_deprec_method": "-1",
    			"h_description": "WEBHOOKTESTER",
    			"h_last_updated": "2020-07-28 08:56:36",
    			"h_last_updated_by": "steveg",
    			"h_location_type": "-1",
    			"h_name": "WEBHOOKTEST",
    			"h_operational_state": "-1",
    			"h_record_state": "1",
    			"h_type": "1",
    			"h_version": "1",
    			"h_booking": "-1",
    			"h_static": "-1"
    		}
    	}
    }

    And this is an example of the Created payload:

    {
    	"onEntityEvent": {
    		"eventSource": "urn:webhook:entity:Asset:created",
    		"callingSessionId": "U2020072800159591",
    		"eventTime": "2020-07-28 08:56:36Z",
    		"actionBy": "steveg",
    		"actionByName": "Steve Goldthorpe",
    		"entity": "Asset",
    		"record": {
    			"h_pk_asset_id": "361",
    			"h_acq_method": "-1",
    			"h_class": "computer",
    			"h_cost": "0.0",
    			"h_created_date": "2020-07-28 08:56:36",
    			"h_deprec_method": "-1",
    			"h_deprec_value": "0.0",
    			"h_description": "WEBHOOKTESTER",
    			"h_disposal_price": "0.0",
    			"h_last_updated": "2020-07-28 08:56:36",
    			"h_last_updated_by": "steveg",
    			"h_location_type": "-1",
    			"h_maintenance_cost": "0.0",
    			"h_name": "WEBHOOKTEST",
    			"h_operational_state": "-1",
    			"h_record_state": "1",
    			"h_residual_value": "0.0",
    			"h_type": "1",
    			"h_version": "1",
    			"h_booking": "-1",
    			"h_static": "-1"
    		}
    	}
    }

    Note the additional auto-assigned properties in the Created payload, including the h_pk_asset_id. So by using the Entity : Asset : Created webhook event, you'll get the information you need:

    image.png  

    Cheers,

    Steve

     

    • Like 1
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...