Users access to a listbox

2009-09-30 Thread Damo Drumm

Hi, at the minute when i add a user to the database they can view all companies 
on a list box. Im trying to reduce this so they will only have access to what i 
enter in a table called USERSvCOMPANYACCESS, which has the Users Key and the 
Company Number in it. Im using the below code, but its displaying all company 
numbers I enter to that table, rather than just the numbers I have chosen for 
that one user.

Can anyone help me out here?

cfquery name=qgetcompany datasource=#request.dsn#
select COMPANY_Number,USERS_Key
from USERSvCOMPANYACCESS
ORDER BY COMPANY_Number
/cfquery

cfloop query=qgetcompany
option value=#COMPANY_Number# 
cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ 
COMPANY_Number)selected/cfif
[#COMPANY_Number#]
/option
/cfloop 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326771
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: Users access to a listbox

2009-09-30 Thread Randy Adkins

It is going to list them all based on your code:

1. Your query is returning ALL records
2. your displaying all OPTIONs in the SELECT dropdown but ONLY selecting the
ones that was populated in the FORM.COMPANY_NUMBER field.

If you only want the SELECT dropdown to return the one in
FORM.COMPANY_NUMBER

then this would work:

cfloop query=qgetcompany
cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ
COMPANY_Number)
option value=#COMPANY_Number# selected[#COMPANY_Number#]/option
/cfif
/cfloop
*** Now this is true if FORM.COMPANY_NUMBER is a SINGLE VALUE not a list.

If you FORM.COMPANY_NUMBER is a LIST, then it would be similar to:

cfif listfind(FORM.COMPANY_NUMBER, COMPANY_NUMBER)
option
/cfif

On Wed, Sep 30, 2009 at 4:49 AM, Damo Drumm damien.dr...@quinn-group.comwrote:


 Hi, at the minute when i add a user to the database they can view all
 companies on a list box. Im trying to reduce this so they will only have
 access to what i enter in a table called USERSvCOMPANYACCESS, which has the
 Users Key and the Company Number in it. Im using the below code, but its
 displaying all company numbers I enter to that table, rather than just the
 numbers I have chosen for that one user.

 Can anyone help me out here?

 cfquery name=qgetcompany datasource=#request.dsn#
 select COMPANY_Number,USERS_Key
 from USERSvCOMPANYACCESS
 ORDER BY COMPANY_Number
 /cfquery

 cfloop query=qgetcompany
 option value=#COMPANY_Number#
 cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ
 COMPANY_Number)selected/cfif
 [#COMPANY_Number#]
 /option
 /cfloop

 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326772
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Users access to a listbox

2009-09-30 Thread Damo Drumm

Ive tried your code, but all its giving me now is a blank list box, with 
nothing to choose in it
It is going to list them all based on your code:

1. Your query is returning ALL records
2. your displaying all OPTIONs in the SELECT dropdown but ONLY selecting the
ones that was populated in the FORM.COMPANY_NUMBER field.

If you only want the SELECT dropdown to return the one in
FORM.COMPANY_NUMBER

then this would work:

cfloop query=qgetcompany
cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ
COMPANY_Number)
option value=#COMPANY_Number# selected[#COMPANY_Number#]/option
/cfif
/cfloop
*** Now this is true if FORM.COMPANY_NUMBER is a SINGLE VALUE not a list.

If you FORM.COMPANY_NUMBER is a LIST, then it would be similar to:

cfif listfind(FORM.COMPANY_NUMBER, COMPANY_NUMBER)
option
/cfif

On Wed, Sep 30, 2009 at 4:49 AM, Damo Drumm 
damien.dr...@quinn-group.comwrote:

 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326773
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Users access to a listbox

2009-09-30 Thread Chuck

You need to filter your data for the User Key that is accessing the code.
You can either put a WHERE clause in your SQL Statement or you can put a
conditional statement around the options looking at the USERS_Key.

Query:

The cfqueryparam is made up and you should use your information to set
that up.

cfquery name=qgetcompany datasource=#request.dsn#
select COMPANY_Number,USERS_Key
from USERSvCOMPANYACCESS
WHERE USERS_Key = cfqueryparam cfsqltype=integer
value=#myUsersKey# /
ORDER BY COMPANY_Number
/cfquery

Conditional:

cfloop query=qgetcompany
cfif qgetcompany.USERS_key EQ myUsersKey
option value=#COMPANY_Number# 
cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ
COMPANY_Number)selected/cfif
[#COMPANY_Number#]
/option
/cfif
/cfloop

HTH
Chuck


~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326774
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Users access to a listbox

2009-09-30 Thread Damo Drumm

That works great Chuck, but is there any way i can change the #myUsersKey# 
which in my case I just replaced it with 25. if other users log on this will 
still hold 25, so id need it to change for every user, if that is possible

You need to filter your data for the User Key that is accessing the code.
You can either put a WHERE clause in your SQL Statement or you can put a
conditional statement around the options looking at the USERS_Key.

Query:

The cfqueryparam is made up and you should use your information to set
that up.

cfquery name=qgetcompany datasource=#request.dsn#
   select COMPANY_Number,USERS_Key
   from USERSvCOMPANYACCESS
   WHERE USERS_Key = cfqueryparam cfsqltype=integer
value=#myUsersKey# /
   ORDER BY COMPANY_Number
/cfquery

Conditional:

cfloop query=qgetcompany
cfif qgetcompany.USERS_key EQ myUsersKey
   option value=#COMPANY_Number# 
   cfif isDefined('FORM.COMPANY_Number') AND (FORM.COMPANY_Number EQ
COMPANY_Number)selected/cfif
   [#COMPANY_Number#]
   /option
/cfif
/cfloop

HTH
Chuck 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326775
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: Users access to a listbox

2009-09-30 Thread Chuck

If your user logs in, then when you do the login authenication you can hold
their userid in Session.  Then use the Session variable in place of the 25,
#Session.YourUserVariable#.


~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326776
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: Users access to a listbox

2009-09-30 Thread Damo Drumm

I dont quite get that
For the user to be able to access this page I add their Windows User Profile to 
a table and from there they can access all the companies
If that makes sence

If your user logs in, then when you do the login authenication you can hold
their userid in Session.  Then use the Session variable in place of the 25,
#Session.YourUserVariable#. 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326777
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


RE: Users access to a listbox

2009-09-30 Thread Chuck

We a user comes to the site, how do you know who they are?  If you run a
query against your database you can store the data in Session and use it in
your query to get the companies they have access to.


~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326787
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4