GET Requests using Filters - Intergraph Smart P&ID - 2.0 - Customization & Programming - Hexagon

Intergraph Smart P&ID Web API Help

Language
English
Product
Intergraph Smart P&ID
Subproduct
Web API
Search by Category
Customization & Programming
Smart P&ID Web API Version
2.0
Smart Electrical Web Version
2.0.1

The following requests use the $filter function. It is a powerful tool to query only what you are looking for. Below are the operators you can define with the filter function.

Operator

Description

Comment

eq

Equal

Performs an exact match on that field

ne

Not equal

Matches on non-matching values

gt

Greater than

Matches when the field is greater than the value

ge

Greater or equal

Matches when the field is greater than or equal to the value

lt

Less than

Matches when the field is less than the value

and

Logical and

or

Logical or

contains

Matches anything that contains the value

startswith

Matches on anything that starts with the value

endswith

Matches on anything that ends with the value

Filters with the 'contains', 'startswith', or 'endswith' operators do not work for properties that are select lists. To verify whether a property is a select list, run a request to display the annotations (02.04 Plant annotations where the metadata appears in each plant) or view the common metadata annotations (where the key used to generate common metadata is set to 'true' in the web.config file) and search for the property in the results. In the example below, the Vessel property 'Item Status' is a select list, whereas the properties 'Description' and 'Item Type Name' are not.

Filter Item Tag

In request 03.06 Specific vessel, you already saw how a filter works. The following request filters for a specific plant item with item tag ‘V-100A’ and additionally queries the number of plant items retrieved using the $count operator.

  • Select the request 04.01 Filter (Plant Item) eq Item Tag and click Send.

    https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
    PlantItems?$count=true&$filter=ItemTag eq 'V-100A'

    The response returns a single item (Vessel) with the requested item tag value.

Filter Case Class

This request gets all the cases whose case class is not equal to 'Process Case'. The request also includes the number of items.

  1. Select the request 04.02 Filter (Cases) ne Process Case and click Send.

    https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
    Cases?$count=true&$filter=CaseClass ne 'Process Case'

    Note the number of cases that are returned with the requested filter.

  2. Now change the ‘ne’ parameter in the request to ‘eq’ and resend the request. Note the number of cases returned.

  3. Next, remove the filter condition completely from the request and resend. The total number of cases returned should be equal to the sum of cases returned by the previous two requests.

Filter starts with

This request gets all the plant items whose Item Type Name property value starts with the string ‘Signal’. The request also includes the number of items.

  • Select the request 04.03 Filter starts with and click Send.

    https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
    PlantItems?$count=true&$filter=startswith(ItemTypeName,'Signal')

Filter ends with

This request gets all the plant items whose Item Type Name property value ends with the string ‘Run’. The request also includes the number of items.

  • Select the request 04.04 Filter ends with and click Send.

    https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
    PlantItems?$count=true&$filter=endswith(ItemTypeName,'Run')

Filter contains

This request gets all the vessels whose Item Tag property value contains the string ‘123’. The request also includes the number of items and some selected properties.

  • Select the request 04.05 Filter contains and click Send.

    https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
    Vessels/Com.Ingr.SPID.V2.WEBAPISITE001.PLANT001.Vessel/?$count=true&$select=Id,ItemTag,
    EquipmentSubclass,EquipmentType,aabbcc_code&$filter=contains(ItemTag,'123')

Filter using logical or

This request gets all the instruments whose item tags contain 'FT' or 'PT'. The request also includes the number of items and some selected properties.

  • Select the request 04.06 Filter using logical OR and click Send.

    https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
    Instruments/Com.Ingr.SPID.V2.WEBAPISITE001.PLANT001.Instrument/?$count=true&$select=ItemTag,
    InstrumentClass,InstrumentType&$filter=contains(ItemTag,'FT') or contains(ItemTag,'PT')

Vessels filtered by equipment type

This request gets all the vessels with a specific equipment type. The request also includes the number of items and some selected properties.

  • Select the request 04.07 Filter (Vessel) eq Item EquipmentType + count + selected properties and click Send.

    https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
    Vessels/Com.Ingr.SPID.V2.WEBAPISITE001.PLANT001.Vessel/?$count=true&$select=Id,ItemTag,
    EquipmentSubclass,EquipmentType&$filter=EquipmentType eq '1 diameter, 1 chamber,
    hemispherical head horizontal drum'