Published on InterSystems Developer Community (https://community.intersystems.com)

Home > ClassMethod with global parameter undefined when attempting to Order

Question
Daniel Lee · May 26, 2020

ClassMethod with global parameter undefined when attempting to Order

I have a class method that accepts a global parameter but when I attempt to order this global, the global name is listed as undefined. I can execute $DATA(pGlobalName) successfully.

ClassMethod ExamineGlobal(pGlobalName As %Global)
 {
    set gStatus=$DATA(pGlobalName) ; returns 1 
    write "This is the global name: "_pGlobalName
    set gmin=$ORDER(pGlobalName("")) ; here pGlobalName is undefined
 }

In debug mode, data returns 1 for a valid global with no descendants. This is expected.

However, when I call $ORDER, it shows <UNDEFINED> for pGlobalName. My guess is that ORDER is operating on the local variable pGlobalName instead of its value? How can I 'dereference' the variable name so that the Order method operates on its value rather than the name itself?

I want to use this for an array of seventy globals and would rather have o single method call to perform work for each global rather than having to explicitly write code for every global. 

Thank you.

I should mention that I am using Cache Ensemble 2010. 

#ObjectScript #Caché

Source URL:https://community.intersystems.com/post/classmethod-global-parameter-undefined-when-attempting-order