Written by

Lead Technical Analyst at Missouri Health Connection
Question Scott Beeson · Jan 21, 2016

[SOLVED (KIND OF)] Missing something obvious trying to do a lookup in a method

So calling this lookup manually from the console works as expected:

PHR>set key = "WMMC_IMM"
PHR>w ##class(Ens.Util.FunctionSet).Lookup("BlockFeed",key)
1

However, calling it from a method with some concatination to build the key is giving me problems:

ClassMethod canSendToState(iParticipant As %String, iFeed As %String) As %Boolean
{
    set = iParticipant _ "_" _ iFeed
    w "Looking up " _ k,!
    set = ..Lookup("BlockFeed",k,"not found")
    w "x = " _ x,!
}
PHR>w ##class("Custom.MHC.Common.Functions").canSendToState("WMMC","IMM")
Looking up WMMC_IMM
x = not found

I really don't understand.  X should be 1 

Comments

Scott Beeson · Jan 21, 2016

so I set iParticipant and iFeed manually in the console then literally pasted the contents of the method to the console and it works.

PHR>set iParticipant = "WMMC"
PHR>set iFeed = "IMM"
PHR>set k = iParticipant _ "_" _ iFeed
PHR>w "Looking up " _ k,!
Looking up WMMC_IMM
PHR>set x = ##class(Ens.Util.FunctionSet).Lookup("BlockFeed",k,"not found")
PHR>w "x = " _ x,!
x = 1


Can anyone explain why? 

0
Stefan Wittmann · Jan 22, 2016

Not sure what is going on here, as the code looks fine. What class do you extend from? The only difference I can spot is that your class method is calling ..Lookup, instead of ##class(Ens.Util.FunctionSet).Lookup

0
Scott Beeson  Jan 22, 2016 to Stefan Wittmann

It extends Ens.Rule.FunctionSet and I'm doing a lookup with the same syntax in another method in the same class.  I'll keep poking it with a stick, there must be something obvious I'm missing.

0
Ray Fucillo · Jan 22, 2016

It's unclear what's going on here, but it would be worth checking the .int version of the compiled class to see if there's anything unexpected (not sure what that might).  Also ensure that the latest version of your code is compiled, though I'm sure you've already done that.

0
Scott Beeson  Jan 22, 2016 to Ray Fucillo

Okay, here is the INT code for both:

Doesn't work:
zcanSendToState(s) public {
..Lookup("BlockFeed",s) }

Does work:
zmyLookup(s) public {
..Lookup("BlockFeed",s) }

I closed studio, reopened it, recompiled everything:

0
Scott Beeson · Jan 22, 2016

Okay I've simplified it greatly.  Here are two methods.  The first one is what's left of the original.  It DOES NOT WORK.  The second one DOES work.

ClassMethod canSendToState(s)
{
    set = ..Lookup("BlockFeed",s)
    q x
}
ClassMethod myLookup(s)
{
    q ..Lookup("BlockFeed",s)
}

 

Why?

0
Scott Beeson  Jan 22, 2016 to Scott Beeson

Bah, I made them IDENTICAL and one still works the other doesn't.  Checking the INT source now...

0
Scott Beeson · Jan 22, 2016

I deleted the class and started from scratch.  Seems to be working.  Can I delete this disaster post?

0