Forum Discussion

Former_Member's avatar
Former_Member
Ideator I
8 years ago

Use multiple "like" conditions in AML query?

Hi, I have:
setType("Part");
setProperty("permission_name", "New %");
setPropertyAttribute("permission_name", "condition", "like");
var item = apply();
How do I change this to use multiple "like" conditions? I want to express something like:   "permission_name LIKE 'New %' OR permission_name LIKE 'In Work %'" Thanks,,,

7 Replies

  • THis doesn't work:
    setType("Part");
    setProperty("permission_name", "New %");
    setPropertyCondition("permission_name", "like");
    var a = newOR();
    a.setProperty("permission_name", "Released %");
    a.setPropertyCondition("permission_name", "like");
  • Neither does:
    setType("Part");
    var a = newOR();
    a.setProperty("permission_name", "Released %");
    a.setPropertyCondition("permission_name", "like");
    var b = newOR();
    b.setProperty("permission_name", "New %");
    b.setPropertyCondition("permission_name", "like");
  • Wow, I just hustled my way through this mud, got my hands dirty and hacked together something that conquered Aras. Here's my victorious Solution:
    setType("Part");
    var a = newOR();
    var b = a.newAND();
    b.setProperty("permission_name", "Released %");
    b.setPropertyCondition("permission_name", "like");
    var c = a.newAND();
    c.setProperty("permission_name", "New %");
    c.setPropertyCondition("permission_name", "like");
    Please tell if this can be gloriously optimized....... I used the docs on www.aras.com/.../Aras.IOM.Item.newOR.html to understand <OR> better.
  • Congretulations to this flawless victory! But a little bit more compact might be a glorious and unmatched Where query, e.g. setAttribute("where", String.Format("[Part].classification like '{0}' and [Part].state = '{1}'" , "Electrical/Resistor/%", "Released")); or setAttribute("where", String.Format("[Part].classification like '{0}' or [Part].classification like '{1}'" , "Assembly/Antenna%", "Electrical/Resistor/%"));
  • Cool, didn't know about "where". Is that simply a partial SQL query? I.e. what would normally follow "WHERE" in an SQL query? The pattern you are using, e.g. "Electrical/Resistor/%", is that SQL or Regex?
  • "Where" is one of the regular AML attributes you can use, such as "action" and "type". In a regular AML query it would look something like this:
    <AML>
     <Item type="Part" action="get" where="...">
    </Item>
    </AML>
    Don´t ask me about the technical background, but I think AML use the dot notation. In my example the pattern refers to my own customized classification tree. We have a quite huge tree with many subclasses. The expression is the string users would normally type into the search bar manually. It would be also possible to use Electrical/Resistor/* instead of /%.