· Aug 25, 2016

Iterate through global

Let's imagine I have a global like this:

^Users(12, "SETTINGS", "IsAllowed") = 1

^Users(41, "SETTINGS", "IsAllowed") = 0

^Users(52, "SETTINGS", "IsAllowed") = 1

Now I would like to check for each user whether they are allowed, therefore I'd need to iterate through the Global. How to do that? It seems that I can't use $Order here like such:

S FF = ""
For {
 S FF=$O(^Users(FF,"SETTINGS","isAllowed"))
 W "User ",FF," is allowed",!

Is there any other way of doing this? 

Discussion (5)0
Log in or sign up to continue

$Query may help, but more likely to be 

S FF = ""
For {
    S FF=$O(^Users(FF))

    I '$D(^Users(FF,"SETTINGS","isAllowed"))#2    {

        W "No settings for user "_FF
    } elseif ^Users(FF,"SETTINGS","isAllowed") {

        W "User ",FF," is allowed",!
    } ELSE {
         W "User ",FF," is not allowed",!

(That assumes the 1/0 value determines whether the user is / is not allowed rather than the existence of the node)