This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - AML Works, IOM does not!

Phil - Friday, January 8, 2010 4:35 PM:

So this is the 3rd time recently in my attempts at trying to do something with the IOM model, that has not worked out for me.

Consider the following IOM code

<code>

Item qryItem = this.MyInnovator.newItem("User", "get");

qryItem.setAttribute("select", "login_name");

qryItem.setProperty("login_name", userName, "eq");

Item results = qryItem.apply();

</code>

 

Now consider the following AML code

<code>

Item qryItem = this.MyInnovator.newItem();
qryItem.loadAML("<Item type='User' action='get' select='login_name'>" +
                            "<login_name condition='eq'>" + userName + "</login_name>" +
                            "</Item>");
Item results = qryItem.apply();

</code>

 

Unless I'm mistaken, these should both produce the same result..however in reality, for the IOM my query just returns ALL of the items, where as the AML version produces the correct results.

Could anybody please explain why I am encountering this??

Thanks for your help.



mbeaulieu - Friday, January 8, 2010 5:07 PM:

Remove the 'eq' from the qryItem.setProperty("login_name", userName, "eq"); line

eq is the default and sometimes causes a problem.



Phil - Friday, January 8, 2010 5:25 PM:

Thanks for the tip...that did make things work... I swear I have tried replacing the "eq" with "like" before and encountered similar behavior....

I'm wondering if I should just make a habit out of using the AML.....



RobMcAveney - Friday, January 8, 2010 5:43 PM:

Removing the "eq" works because the default condition is always "eq".  To be clear though, the (optional) third parameter of the setProperty method is the language code, not the condition.  I think condition used to be in there, but that was changed quite some time ago.

If you ever get different results than you expect in IOM, you can always inspect the AML that is getting submitted using qryItem.dom.InnerXml.  In your original code it would have looked like this:

<Item isNew="1" isTemp="1" type="User" action="get" select="login_name">
 <i18n:login_name xml:lang="eq" xmlns:i18n="www.aras.com/.../i18n:login_name>
</Item>

It may not be immediately obvious what was happening, but at least you know what's being submitted.  Method code can be written using either IOM or AML -- both are fine.  I tend to use IOM about 90% of the time though.  There are a couple of quirks, but it's normally easier than writing out the AML.

Rob



carterdawson - Sunday, October 9, 2011 10:06 PM:

I just got bitten by this issue today, and I just found the source of the confusion.

Recipe 7.2 in the Innovator 9.2 Programmer's Guide uses "gt" as the third parameter:

  qryItem.setProperty("cost", "100", "gt");

This is kind of a "goto" recipe for a lot of situations, and I'll be it's confounding people all over the place.

Shaun

 

 



Brian - Tuesday, October 11, 2011 6:43 AM:

You need to use the "setPropertyCondition(propertyName, Condition)" call to set conditions like "eq" or "like"

Cheers,

Brian.