You can see I was using my order number (pNumber) in the name:
parameter. This did return what appeared to be an OK order object,
but if applescript had to go back and reference the order as it did
in my example...
set myOrder to first order whose number is orderNumber
customer name of myOrder
...then it couldn't find the order since it used the order number to
try to find the order name.
Interestingly, the applescript:
customer name of first scheduled order whose id is orderNumber
...does not even cause the -objectSpecifier method to be called,
which it why it always worked, despite the poor form of my code in
that method previously.
So what made it work for me was to return the order name in the
"name:" parameter in my -objectSpecifier method, but I believe that
what I will do is consider to use NSUniqueIDSpecifier with my order
number.
I'm in kind of a funny spot because the primary identifier of an
order at my company is the production number or order number, which I
think best corresponds to the applescript "name" property, but then
we also have an order name such as "Cleveland Water Treatment Plant
Job" or similar, so I have to make a decision of which of these
properties is the best applescript "name" for an order.
Thanks again everybody, I feel I have a much better handle on this.