• 1 reply
  • Latest Post - ‏2014-03-19T18:07:35Z by llandale
3 Posts

Pinned topic AccessRec of specific AttrType

‏2014-03-19T13:52:44Z |

the get() command for AccessRec's is in the manual as:

AccessRec get({Object o|Module m|Project p|Folder f|Item i|View v},

[AttrType at,]

string user,

string &message)

However, I keep getting the following error when attemting to get the AccessRec of specific AttrType(s) when I include the optional  AttrType:

"<Line:12> null AccessRec parameter was passed into argument position 1"

I'm basically understanding this to mean that the get() command is returning a null access record. But if I open the attribute types list from the menu bar (i.e. Edit > Types...) and open individual types, they all show access permissions (some are inherited, some are not).

If I include a if(!null ar) statement to avoid null access records I simply get no output... but I want to get the access rights to each type. I'm not sure what I'm missing, any help is appreciated.

here's how my code works...

AttrType at
Module m = current Module
AccessRec ar
string msg

for at in m do
    for ar in at do
  ar = get(m,at,doorsname,msg)

  if (read ar) print "read"
  if (modify ar) print "modify"
  if (create ar) print "create"
  if (delete ar) print "delete"
  if (control ar) print "control"

  print "\n"





Updated on 2014-03-19T13:53:28Z at 2014-03-19T13:53:28Z by developerTom
  • llandale
    3035 Posts

    Re: AccessRec of specific AttrType


    I think you are confusing an "AccessRecord" with the notion of "Permission".  Line 10:  You will get a null "ar" unless there is an actual AccessRecord for the current user specifically.  So if  the single record is"everyoneElse" has "RMCDA", then the current user (doorsname) does NOT have an AccessRecord.  I think you want to investigate "hasPermision" commands.

    Line 8 and 10 do not combine; where line 10 changes the loop control handle in line 8.  You can either loop (line 8) and print the current AccessRecords, OR try to find Permission for the current user.

    Be advised that the

    • hasPermission et tal command tells you about how AccessRecords combine to provide permissions.
    • "canDelete" et tal commands tell you if the user can delete the thing right now; implying the user has both Permission and also Access (e.g. module open edit).
    • So if the script doesn't want to attempt to delete without access, "canDelete" will work.  However, I prefer to just go ahead and delete it and trap and report any errors in the attempt.