Sharepoint Designer Filter
-
2012年5月10日 19:38
I'm exhausted on my google searching so I thought I'd post this question. This is for Sharepoint Designer 2010.
I have a list column that contains my user id. I want to put a filter on a DataFormWebPart that says column1 contains [Current User]. It does not work. My user id, for example, is k99999 while Current User, I think, returns domain\\k99999. That's fine so I tried a substring. Which also didn't work. If I try, in the filter, column1 contains 'k99999' (ie hard code the value) the filter does work.
So the question is what do I need to do for Current User to get it to work? Is it returning a value I'm not expecting that causes the substring not to work? I'm stumped. I hope I've explained the scenario clearly.
すべての返信
-
2012年5月10日 21:29
Is the column of the type Person or just string. If it is not person then the [Current User] won't work.
Try converting the column to person and try it again.
Ameet Phadnis (Alexander Open Systems)
-
2012年5月10日 22:49
Hi
let me point 3 aspects
-- use Bing, it's work better
--use [Me] as filter for current user, should work
-- the domain user's name using domain name could be Domain_name\user_name
for shares, the name is \\Domain_name\share_name
Romeo Donca, Orange Romania (MCSE, MCTS, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.
-
2012年5月11日 12:21The column is a multiple entry Person or Group column. I'm trying to use the column to assign users to a department. I don't think I'll be able to accomplish what I want through security and permissions so I'm going this route. So I could have k99999 and k99998 users listed in the column with the hopes that a column1 contains [Current User] would work. but it hasn't so far.
-
2012年5月11日 12:23
I just tried [Me] and it too did not work. My filter looks like this Column1 Contains '[Me]'
Is that the correct syntax. Earlier I tried Colunn1 Contains '[Current User]' and Column1 Contains 'substring([Current User], 9)' Neither of those worked. As I mentioned when I hard code a value it does work.
-
2012年5月11日 14:02
I just tried this in my environment and it worked fine -
1. My list columns are -
- Title
- TestingUsers - Type Person / Group. Allow Multiple entries.
2. Added Myselft and a co-worker to the item.
3. SharePoint Designer used Filter and it says
- FieldName = TestingUsers
- Comparison = Equals
- Value = [Current User]
On page source code if you look at the page it has a variable declared as -
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
Query as -
<Query>
<Where>
<Eq>
<FieldRef Name="TestingUser"/>
<Value Type="Integer">
<UserID/>
</Value>
</Eq>
</Where>
</Query>Try it on a separate new list and see if it works. If it does then try it on your current list.
Thank You,
Ameet
Ameet Phadnis (Alexander Open Systems)
-
2012年5月14日 12:27
It did not work.
Here is the code it generated:
<Query>
<Where>
<Eq>
<FieldRef Name="testingusers"/>
<Value Type="UserMulti">[Current User]</Value>
</Eq>
</Where>
</Query>Since the testingusers field is a multi-value field wouldn't we want the Contains clause rather than Equals? Even so Contains wasn't an available option when I tried this particular test in SPD. Also, how did you define your test users field was it Name (with presence), Account?? This really has me stumped.
-
2012年5月14日 14:39
Not sure what the Value Type="UserMulti" is. This is SharePoint 2010 right? Questions -
1. Did you select Person or Group as Type when creating the list?
2. Under Allow Multiple selections you selected Yes
3. Under Allow Selection of People only radio button is on.
4. Under Choose From - All Users radiobutton is selected.
5. Under Show Field - Name (with Presence) is selected.
After doing the above my entire XML is as follows - Please note that my query has the type as integer and checks the userid.
<WebPartPages:XsltListViewWebPart runat="server" IsIncluded="True" GhostedXslLink="main.xsl" NoDefaultStyle="TRUE" ViewFlag="8" Title="test" PageType="PAGE_NORMALVIEW" ListName="{4C5D21FE-D9F3-4E99-B3E4-E47352CA4537}" Default="FALSE" DisplayName="test" __markuptype="vsattributemarkup" __WebPartId="{36F4AC4F-F717-4D73-9D79-A27D5B6AD139}" partorder="2" id="g_36f4ac4f_f717_4d73_9d79_a27d5b6ad139" viewcontenttypeid="0x" __designer:customxsl="fldtypes_Ratings.xsl">
<XmlDefinition>
<View Name="{B8F00115-F90F-49B0-8946-00B984FD6E40}" MobileView="TRUE" Type="HTML" DisplayName="All Items" Url="/sites/bank/Acc/Lists/test/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png">
<Query>
<Where>
<Eq>
<FieldRef Name="testuser"/>
<Value Type="Integer">
<UserID/>
</Value>
</Eq>
</Where>
</Query>
<ViewFields>
<FieldRef Name="Attachments"/>
<FieldRef Name="LinkTitle"/>
<FieldRef Name="testuser"/>
</ViewFields>
<RowLimit Paged="TRUE">30</RowLimit>
<Toolbar Type="Standard"/>
</View>
</XmlDefinition>
<parameterbindings>
<ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/>
<ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/>
<ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/>
<ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)"/>
<ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)"/>
<ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)"/>
<ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)"/>
<ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/>
<ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)"/>
<ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)"/>
<ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)"/>
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
</parameterbindings></WebPartPages:XsltListViewWebPart>Ameet Phadnis (Alexander Open Systems)
- 回答としてマーク Emir LiuMicrosoft Contingent Staff, Moderator 2012年5月17日 6:00
-
2012年5月14日 14:40
Not sure what the Value Type="UserMulti" is. This is SharePoint 2010 right? Questions -
1. Did you select Person or Group as Type when creating the list?
2. Under Allow Multiple selections you selected Yes
3. Under Allow Selection of People only radio button is on.
4. Under Choose From - All Users radiobutton is selected.
5. Under Show Field - Name (with Presence) is selected.
After doing the above my entire XML is as follows - Please note that my query has the type as integer and checks the userid.
<WebPartPages:XsltListViewWebPart runat="server" IsIncluded="True" GhostedXslLink="main.xsl" NoDefaultStyle="TRUE" ViewFlag="8" Title="test" PageType="PAGE_NORMALVIEW" ListName="{4C5D21FE-D9F3-4E99-B3E4-E47352CA4537}" Default="FALSE" DisplayName="test" __markuptype="vsattributemarkup" __WebPartId="{36F4AC4F-F717-4D73-9D79-A27D5B6AD139}" partorder="2" id="g_36f4ac4f_f717_4d73_9d79_a27d5b6ad139" viewcontenttypeid="0x" __designer:customxsl="fldtypes_Ratings.xsl"> <XmlDefinition> <View Name="{B8F00115-F90F-49B0-8946-00B984FD6E40}" MobileView="TRUE" Type="HTML" DisplayName="All Items" Url="/sites/bank/Acc/Lists/test/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/images/generic.png"> <Query> <Where> <Eq> <FieldRef Name="testuser"/> <Value Type="Integer"> <UserID/> </Value> </Eq> </Where> </Query> <ViewFields> <FieldRef Name="Attachments"/> <FieldRef Name="LinkTitle"/> <FieldRef Name="testuser"/> </ViewFields> <RowLimit Paged="TRUE">30</RowLimit> <Toolbar Type="Standard"/> </View> </XmlDefinition> <parameterbindings> <ParameterBinding Name="dvt_sortdir" Location="Postback;Connection"/> <ParameterBinding Name="dvt_sortfield" Location="Postback;Connection"/> <ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue=""/> <ParameterBinding Name="dvt_firstrow" Location="Postback;Connection"/> <ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)"/> <ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)"/> <ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)"/> <ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)"/> <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)"/> <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(core,noXinviewofY_DEFAULT)"/> <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)"/> <ParameterBinding Name="MoreAnnouncements" Location="Resource(wss,moreItemsParen)"/> <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/> </parameterbindings></WebPartPages:XsltListViewWebPart>Ameet Phadnis (Alexander Open Systems)
-
2012年5月14日 14:40
Thanks for your assistance I think I found the answer.
I continued to search and came across this: http://www.hornerit.com/2010/08/filtering-data-view-web-part-to-current.html
I modified my code as he suggested and it seems to have worked. I can add more detail here if you're curious.
- 回答としてマーク Emir LiuMicrosoft Contingent Staff, Moderator 2012年5月17日 6:00

