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:
For {
S FF=$O(^Users(FF,"SETTINGS","isAllowed"))
Q:$L(FF)
W "User ",FF," is allowed",!
}
Is there any other way of doing this?
You can use $order to order all users, in global
Hi Sebastian,
Set FF = ""
For {
Set FF=$Order(^Users(FF))
If FF="" Quit
If $Get(^Users(FF,"SETTINGS","isAllowed"))=1 {
Write !,"User ",FF," is allowed"
}
}
Rgds
set key = $O(^Users(""))
While key '= ""
{
if ($DATA( ^Users(key,"SETTINGS","isAllowed"))>0)
{
set isAllowed = ^Users(key,"SETTINGS","isAllowed")
}
set key = $O(^Users(key))
}
Note that Dmitry's answer and mine are pretty much the same, except that I like to avoid post conditional commands where it´s not strictly needed
$Query may help, but more likely to be
S FF = ""
For {
S FF=$O(^Users(FF))
Q: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)