Thursday, June 27, 2013

Using new operators for Id field in SOQL (Summer '13 feature)

Starting with the Summer '13 release you'll be able to in SOQL use additional comparison operators on the Id field, such as <, >, and >=.  Once I was at an intro session to the new release, and an audience member asked, "Why do we need those?"  Good question.  I actually had no answer for it.  Indeed ordering by Id seems to be an awkward way to locate things.

Today I found a good use for it.  My task was to get all customized profile names and stick them in my package.xml along with a whole bunch of stuff to deliver their permissions at the same time.  I was surprised to see there's no indicator field on the Profile object to tell me which ones are custom.  So my solution was to use Id since all the standard profiles start with '00e70000000', and custom ones start with '00e70000001'.  Do a simple id > in the WHERE clause, and I'm all set.

Not a significant use, I know.  Hey beats nothing, doesn't it?

Footnote: why did I need to do only custom profiles?  Because for some reason, the metadata API (via ANT) doesn't want to take standard profile names (neither retrieve nor deploy).

No comments:

Post a Comment