Question

Automation Workflow - Query Service Item Settings

  • 12 April 2024
  • 5 replies
  • 34 views

Badge +1

Hey All,

I am trying to create an automation workflow that checks if a particular product is in stock, and if it is to then proceed with the ticket. Does anyone know how I can query a service item asset type?

 

This is the field I am trying to reference and check if the asset_state=in stock. 

 

Here is an example of the workflow: 

 

I’m not sure if this is the best approach or I need to take a different approach. All help would be appreciated. 

Regards,

Mark


5 replies

Userlevel 7
Badge +13

https://api.freshservice.com/v2/#filter_assets

with this &filter="asset_state:%27IN%20STOCK%27%20AND%20asset_type_id:xxxxx  you should get all that in stock. 

Expression if(‘{{asset_id}}’ == ‘’, true.false) would give you if there are non left. 

I guess you are doing something like that already. I don’t see any other way. 

Badge +1

Thanks so much! I managed to get this working to some form of degree! haha. 

Does anyone know how to reference product_name in the endpoint url? I can see it exists in the items.json but doesn’t exist in the web request for some reason…

Bellow is the .json which shows it’s available option: 

 

But this does not show in the endpoint url output… Not sure if I am supposed to reference something else?

 

{
"assets": [
{
"type_fields": {
"product_75000041824": 75000036790,
"vendor_75000041824": null,
"cost_75000041824": null,
"warranty_75000041824": null,
"acquisition_date_75000041824": null,
"warranty_expiry_date_75000041824": null,
"domain_75000041824": null,
"asset_state_75000041824": "In Stock",
"serial_number_75000041824": null,
"last_audit_date_75000041824": null,
"os_75000041829": null,
"os_version_75000041829": null,
"os_service_pack_75000041829": null,
"memory_75000041829": null,
"disk_space_75000041829": null,
"cpu_speed_75000041829": null,
"cpu_core_count_75000041829": null,
"mac_address_75000041829": null,
"uuid_75000041829": null,
"hostname_75000041829": null,
"computer_ip_address_75000041829": null,
"last_login_by_75000041829": null,
"asset_notes_75000041829": null,
"data_sim_number_75000041846": null,
"flagged_for_replacement_75000041846": false,
"asset_notes_75000041846": null,
"depreciation_id": null,
"salvage": null
},
"name": "Muk Test Laptop",
"asset_type_id": 75000041846,
"asset_tag": "MD10001",
"impact": "low",
"description": "This is some form of test test test.. yewwe",
"end_of_life": "2027-04-09",
"discovery_enabled": true,
"usage_type": "permanent",
"created_by_source": "User",
"created_by_user": "Mark",
"created_at": "2024-04-15T01:49:13Z",
"last_updated_by_source": "User",
"last_updated_by_user": "Mark",
"updated_at": "2024-04-15T01:49:13Z",
"location_id": 75000014452,
"department_id": null,
"agent_id": null,
"user_id": null,
"group_id": null,
"assigned_on": null,
"author_type": "User",
"id": 120000038506,
"display_id": 1
}
]
}

 

Userlevel 7
Badge +13

API just shows ID for the asset type/product. 

Badge +1

Appreciate it! :) 

Not sure if you know or not… But let’s say I have 600 products and 400 results, and the API only allows 100 results per-page. Let’s say out of the 400 results I am looking for a product ‘HP ProBook 430 G8’ and it’s on page 2, but the more products I add that product I am after moves to page 3, page 5, page 6 over time. How am I supposed to dynamically look for something not dependent on the page number?

I can’t find this at all… it seems like the freshservice method is a static identification. (I am a few weeks new to this product, so apologies). Is API web-request the only way to do this? Or is there a more advanced method I should be using? I find it hard to believe that this product only ever limits 100 resasults in things when people may need more than that. So, it leads me to believe my approach my not be the correct way.

Userlevel 7
Badge +13

Don’t know why(I guess performance) the filter would give us just 100 but it’s how it’s built and I don’t see any other way. When they get loop function in the automation I hope we can use that to loop pages. 

A workaround is to use Powershell to loop the assets but then you need a orchestrating server.   

Reply