For SalesManagers I have an Account query that displays a form with various fields including: AssignedToLoginName, a shortcut to RegularUser.LoginName.
When used, if all fields are left empty all Accounts are found.
I want to have similar functionality for SalesPersons, except that SalesPersons should only ever be able to see accounts that have not been assigned to them. They should never be able to get to accounts that are assigned to anyone else.
I can't reuse the search form for SalesManagers because it has the field AssignedToLoginName. So I make another form that doen't have it.
Then I make another Query that uses that form. At this point I get stuck.
What I need I guess is for AssignedToLoginName to be on the form with its value set to LoggedInRegularUser.LoginName.
Or I need to somehow qualify the search parameters with that value.
Any suggestions?
thanks,
Terry
presetting query values
-
- Posts: 595
- Joined: Sun Apr 24, 2005 2:22 am
- Contact:
Terry,
You can do a couple of things to implement your requirements in a very efficient way.
First, add a protection rule to Account to disallow sales people to see the account unless assigned to them:
If LoggedInSystemUser.AccessLevel = 'SalesPerson'
AND Account.AssignedToLoginName <> LoggedInSystemUser.LoginName
Then READ PROTECT Account FROM SalesPerson
With this rule in place the system will automatically ensure that other sales people will never see the account whether in query results, reference attribute on related object forms, reports, etc. This means you can reuse the sales manager query for sales people and the system will automatically filter out unwanted accounts.
Second, since sales people are only ever allowed to see their own accounts, it makes sense to hide the Account.AssignedToLoginName from them altogether. You can do it by selecting Not Available for the attribute in the SalesPerson access level. Then you can also reuse the search form for sales managers since the system will automatically hide the attribute on the form.
On a related note, consider replacing the text attribute Account.AssignedToLoginName to a reference attribute Account.AssignedSalesPerson of type SalesPerson. One reason is that the person may decide to change their login name at some point, which will break the validation. Another reason is that it will make the search easier for the sales manager because rather than having to type some login name he would simply choose from a list of sales people. Then the protection rule would look like this:
If LoggedInSystemUser.AccessLevel = 'SalesPerson'
AND Account.AssignedSalesPerson <> LoggedInSystemUser
Then READ PROTECT Account FROM SalesPerson
You can do a couple of things to implement your requirements in a very efficient way.
First, add a protection rule to Account to disallow sales people to see the account unless assigned to them:
If LoggedInSystemUser.AccessLevel = 'SalesPerson'
AND Account.AssignedToLoginName <> LoggedInSystemUser.LoginName
Then READ PROTECT Account FROM SalesPerson
With this rule in place the system will automatically ensure that other sales people will never see the account whether in query results, reference attribute on related object forms, reports, etc. This means you can reuse the sales manager query for sales people and the system will automatically filter out unwanted accounts.
Second, since sales people are only ever allowed to see their own accounts, it makes sense to hide the Account.AssignedToLoginName from them altogether. You can do it by selecting Not Available for the attribute in the SalesPerson access level. Then you can also reuse the search form for sales managers since the system will automatically hide the attribute on the form.
On a related note, consider replacing the text attribute Account.AssignedToLoginName to a reference attribute Account.AssignedSalesPerson of type SalesPerson. One reason is that the person may decide to change their login name at some point, which will break the validation. Another reason is that it will make the search easier for the sales manager because rather than having to type some login name he would simply choose from a list of sales people. Then the protection rule would look like this:
If LoggedInSystemUser.AccessLevel = 'SalesPerson'
AND Account.AssignedSalesPerson <> LoggedInSystemUser
Then READ PROTECT Account FROM SalesPerson
Aware IM Support Team