Share via


How can the [Me] variable be used to filter fields like UserName other than Created By or Modified By or the Assigned To in a list view?

Question

Tuesday, August 23, 2011 3:36 AM

Hi all,

How can the [Me] variable be used to filter fields like UserName other than Created By or Modified By or the Assigned To in a list view ?

For example, in a salary list ,the user can only see his or her own salary item. I created a list view filtered by UserName=[Me] and When logon using a UserName,there is no item to see at all.

Thanks in advance.

All replies (23)

Friday, August 26, 2011 8:39 AM ✅Answered

Well if you only want to filter the list view,, try using the Current User filter webpart ...http://www.sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?ID=99

 

But as i said it will just filter the view and not stop access to all items.. you have to put some security trimming on items as well, may explicitly, so what you can do is write a receiver that sets some security targeting on the items that ways you dont have to filter the view... the event receiver can add the intended user in the target so that ways who creates the item is not important... hope you get the idea.

"T" | community.zevenseas.com/Blogs/Tanmay/default.aspx


Tuesday, August 23, 2011 3:44 AM | 1 vote

Refer to this post

http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/b37d152e-a483-4699-960b-1303cf62d792

- Sid


Tuesday, August 23, 2011 3:51 AM | 1 vote

Yes, you can use [Me] to do some filtering, a couple of posts which may help you. This first one is on advanced filtering.

https://www.nothingbutsharepoint.com/sites/eusp/Pages/sharepoint-me-easy-item-level-security.aspx

The next one talks about the limits of the 'Me' 

http://social.msdn.microsoft.com/Forums/en-AU/sharepointdevelopment/thread/4198f0d4-691c-4bac-b6c1-c9c1ebe475b1

Another on advanced filtering which may help you.

http://blog.pentalogic.net/2008/10/advanced-sharepoint-view-and-filters/

Good luck,

Gary

blog www.sharepoint2010now.com 

 

Gary Newman MCSE, MCT, CCNA MCDBA, MCAD, MCSA MCTS SharePoint 2007 Dev & Admin MCPD SharePoint 2010 Development My Blog www.sharepoint2010now.com


Wednesday, August 24, 2011 1:42 AM

Thanks for the replies Sid and Gary,According to your link, I tried the people/group column,but it does not work. Why?


Thursday, August 25, 2011 2:28 AM

Hi,

 

The Me function returns the current user name, please make sure  the value of people or group column is the same with the value the Me function returns.

To check the value  of Me function, you can create a single line of text column and set it’s default value as Calculated value: =[Me], then you will see the value when creating in list itemXue-Mei Chang


Thursday, August 25, 2011 3:17 AM

Thanks for the reply Xue-Mei, I did not derectly input the value of people or group column  but used seaching  and then selected from the available value .


Thursday, August 25, 2011 3:48 AM

Hi,Xue-Mei

I created a single line of text column and set it’s default value as Calculated value =[Me],then logon as defferent users,but no value at all in the column.


Thursday, August 25, 2011 4:02 AM

Cxr,

Did you add a new record to the list/library. Only then the value of the calculated column be displayed. Not for the existing records.

- Sid


Thursday, August 25, 2011 4:54 AM

Hi cxr,

Yes, you should add a new item in the list to check the Me function value, the default value will display in the column when creating new item.

Xue-Mei Chang


Thursday, August 25, 2011 6:22 AM

Thanks Sid,It's OK for new records.  But why it cann't  be used to filter fields like UserName ?


Thursday, August 25, 2011 7:58 AM

Hi, why do you want to use the filter at all... given the example of salary list, i dont think you would any other user to see or edit others records... so you can just change the List Settings --> Advanced Settings ... you can set the access rights for items in the list as  Read access = own  and Edit Access = own ... this way on this list users will only be able to read and edit their own items and will not see any others... hope that helps."T" | community.zevenseas.com/Blogs/Tanmay/default.aspx


Thursday, August 25, 2011 8:17 AM

Thanks Tanmay,

The salary list is created by Human department and read by employees in the company.


Thursday, August 25, 2011 12:20 PM

ok get it.. but then even if you use a current user filter on the view the users (smart ones) can still get to other records using URL tampering.. just the filtering on the view won't work.

you need to have additional setup or things to keep the users data safe then.

"T" | community.zevenseas.com/Blogs/Tanmay/default.aspx


Thursday, August 25, 2011 10:55 PM

Thanks Sid,It's OK for new records.  But why it cann't  be used to filter fields like UserName ?

Because [Me] returns account name in the format i:0#.w|domain\username and the people picker field (UserName) in your list must be set to show "Name (with presence)" by default. If you change that to "Account", you should get the same format as [Me]- Sid


Thursday, August 25, 2011 11:47 PM

Hi Sid,

Can you show me the detial steps to do that?


Thursday, August 25, 2011 11:49 PM

Thanks  for your advice,Tanmay.  any good solution?


Friday, August 26, 2011 12:56 AM

1. Go to your list settings.

2. Select the column UserName.

3. Right at the bottom, you will see Show Fields. Select "Account" from the drop-down. Click OK.

4. Modify your view

5. Under Filters, choose "Show items only when the following is true"

6. Select "UserName" column; choose "is equal to"; provide condition as [Me] in the textbox

- Sid


Friday, August 26, 2011 1:47 AM

Hi Sid,

 I did that according to the steps, it still doesn't work .

Thanks very much anyway.

By the way , I'm in a standalone other than domain environment.

 


Friday, August 26, 2011 2:10 AM

Well, You've got to put some screen shots to show what you are getting when you put [me] as a calculated value and when you change UserName to show Account. Those values should match- Sid


Friday, August 26, 2011 2:59 AM

My environment is not English but Chinese. So screen shots may be not understandable for you.


Friday, August 26, 2011 5:42 AM

[Me] will return the current logged-in users Login-name.

probably, your List has values stored inform of User-names.

that is why ur getting error.

 

so, goto List settings and click on the username column and set its property to User-name(it is presently loggin-name).

 

thats it!


Friday, August 26, 2011 8:15 AM

Hi ogsim07,

Thank you for your reply.

The username column's property is set to User-name(it is presently loggin-name) by default, it's not work.

 


Wednesday, December 18, 2019 6:05 PM

Just a hint:  Our SP is setup with German language.

[Me] isn't me - but in German it is [Ich]  
[Today] is [Heute]  ... very annoying.

Other readers may have same Language issues - even decades later :) ?