Applies To:
  • CitectSCADA 1.00 1.01 1.10 1.11 1.20 2.00 2.01

If you get the current user's area (using the function GetArea), modify that area, and then use SetArea to change the current user's area, the SetArea will fail. This occurs because you are modifying the current user's area, and just before SetArea uses its new area, it deletes the current users area. This will cause SetArea to get an area of 0. 

To work around this problem, make a copy of the user's area and modify that area. If you pass this new area back to SetArea the current user's area will be set correctly. For example.

hUserArea = GetArea(); ! get the current users area
hTemp = GrpOpen("temp", 1): ! create a new group
GrpInsert(hTemp, hUserArea); ! copy user area into temp
... ! modify group as required, using GrpDelete, GrpInsert etc
SetArea(hTemp); ! set the new user area
GrpClose(hTemp); ! close the temp group

Note that to set a new area, the current logged in user must have the allowable Viewable Areas - to have that area selected. If the user does not have rights to view that area, SetArea will ignore that area.