This topic is locked
[SOLVED]

 Hiding Add New Button based on Security Group

1/4/2011 2:58:34 PM
ASPRunnerPro General questions
M
Mike Nagel author

OK ... I'm going nuts.
I'm trying to hide the Add New button in ASPRunner 6.3 when the Group of the individual logged in does not match the Group of the individual who created a parent record. I can do this by hard-coding the Group code thus (into the "Before display" event of the child page):
strSecurityGroup = "00"
if Session("GroupID")= strSecurityGroup then

xt.assign "newrecord_controls",true

else

xt.assign "newrecord_controls",false

end if
This works and hides the Add New button when an individual's Security Group is not "00."
The next step is to set the strSecurityGroup value to the value of the "owner_id" field displayed in the parent page. In other words, only the individuals who created the parent record can create associated child records.
For the life of me, I cannot figure out how to refer to the parent form's "owner_id" field.
Help!

Sergey Kornilov admin 1/4/2011

Mike,
you need to execute SQL Query in order to retrieve owner_id field value from the master table.
Master record ID is stored in session variable SESSION("<table name>_masterkey1").

set rs = CustomQuery("select owner_id from MasterTable where PrimaryKey = " & SESSION("<details table name>_masterkey1"))

strSecurityGroup = rs("owner_id")


Make sure you replaced all field and table names with correct ones.
More info on session variables:

http://xlinesoft.com/asprunnerpro/docs/asprunner_session_variables.htm
On DAL functions:

http://xlinesoft.com/asprunnerpro/docs/customquery.htm

M
Mike Nagel author 1/5/2011

Sergey,
After a couple of false-starts, I got it working. Thanks so much for your help! :-)