This article provides two scripting examples of how to filter to find items based on whether or not they have Description content.


Filter and Variable Example 

In this example, the goal is to return items that have description content. In order to do this, we use the <DescriptionIsEmpty/> filter together with <NOT> to negate the filter. After defining the filter, we can iterate over a list of items using ForEach and call the filter using an <If filter=""> tag.   

...
<Filter name="IsDescriptionNotEmpty">
    <NOT>
        <DescriptionIsEmpty/>
    </NOT>
</Filter>

<!--Variable defined as following-->
<Variable name="HIwithDescription" select="/ITSR" as="[Item]"/>

...

<ForEach select="$HIwithDescription">
    <If filter="IsDescriptionNotEmpty">
        <!—do something… -->
    </If>
</ForEach>
...


Filter and Function Example

Another way to do the filtering is to use a function that calls a filter, and then use the function in any path query.  

<Report>
   
    <Filter name="F1">
        <DescriptionIsEmpty/>
    </Filter>

    <Function name="IsEmptyDesc" as="Boolean">
        <Parameter name="para1" as="[Item]"/>
        <Choose>
            <When filter="F1">
                <Value select="false"/>
            </When>
            <Otherwise>
                <Value select="true"/>
            </Otherwise>
        </Choose>
    </Function>

    <!--Check if the current item has an empty Description-->
    <Text>#{? IsEmptyDesc(.)}</Text>
    <!--Return the item with empty  Description-->
    <Text>#{? /ITSR[IsEmptyDesc(.)]}</Text>

</Report>