Forum Discussion

AngelaIp's avatar
AngelaIp
Ideator I
6 months ago
Solved

What does the "isCriteria" attribute do?

Hi Community,

what is the purpose of the "isCriteria" attribute? It´s described in the programmers guide like this:

"If 0 then include the nested structure for the Item configuration in the response but don't use it as search criteria. Default is 1, which uses the nested structure in the request as search criteria."

I tested the attribute with an AML query with relationships. I even tested original Aras queries that use the attribute. I never noticed any difference in the query result. 

Does anyone know more?

  • Hi Angela,

    This is one of those niche attributes which likely is very useful but only in specific circumstances.

    This is intended to be used when you are expanding on Item properties or relationships where you want to expand on some data if it exists, but you don't want to limit your results if it doesn't.

    As an example of an AML query that does change when you use this attribute, we can look at this query where we are trying to get all of our PRs with a specific affected Item. 

    <AML>
        <Item type="PR" action="get">
            <affected_item>
                <Item type="Part" action="get">
                    <item_number>Part-123</item_number>
                </Item>
            </affected_item>
        </Item>
    </AML>

    In the above example, we would get only the PRs with specifically Part-123 as the affected item. If we instead change this query to use the `isCriteria` attribute:

    <AML>
        <Item type="PR" action="get">
            <affected_item>
                <Item type="Part" action="get" isCriteria="0">
                    <item_number>Part-123</item_number>
                </Item>
            </affected_item>
        </Item>
    </AML>

    We will get all of the PRs in our database whether or not the affected item is Part-123. The only difference is that the affected_item property in this example will be expanded for specifically those PRs that do have Part-123 as its affected item. 

    Hope this helps!

    Chris

2 Replies

  • Hi Angela,

    This is one of those niche attributes which likely is very useful but only in specific circumstances.

    This is intended to be used when you are expanding on Item properties or relationships where you want to expand on some data if it exists, but you don't want to limit your results if it doesn't.

    As an example of an AML query that does change when you use this attribute, we can look at this query where we are trying to get all of our PRs with a specific affected Item. 

    <AML>
        <Item type="PR" action="get">
            <affected_item>
                <Item type="Part" action="get">
                    <item_number>Part-123</item_number>
                </Item>
            </affected_item>
        </Item>
    </AML>

    In the above example, we would get only the PRs with specifically Part-123 as the affected item. If we instead change this query to use the `isCriteria` attribute:

    <AML>
        <Item type="PR" action="get">
            <affected_item>
                <Item type="Part" action="get" isCriteria="0">
                    <item_number>Part-123</item_number>
                </Item>
            </affected_item>
        </Item>
    </AML>

    We will get all of the PRs in our database whether or not the affected item is Part-123. The only difference is that the affected_item property in this example will be expanded for specifically those PRs that do have Part-123 as its affected item. 

    Hope this helps!

    Chris

    • AngelaIp's avatar
      AngelaIp
      Ideator I

      Hi Chris

      The samples helped a lot, I see the difference in the result! There are a couple of attributes that are rarely needed, but when they are, they can significantly improve specific use cases.

      "isCriteria" is definitely a niche attribute, but if I remember correctly I once solved something similar with logic ORs and a lot of try and error. Now I know better :). 

      Thanks for the fast help!

      Angela