I am populating a dropdown list by creating a data connection. It works fine, but I need to filter out documents which are only created by the current logged in user.

I don't see an option to filter the documents what were created by the current user in the document library.

Any help is appreciated.

Update

How should I check the AccountId of the document against email retrieved using a data connection? I am able to use a formula or type a text. I don't have an option to select a data source.

enter image description here

有帮助吗?

解决方案

In infopath you will use the filter in the control for this. When you go to the Drop-Down list properties When you choose the option for "Get choices from an external data source" you can pick your doc lib. (I suspect that you have already got this part done by the wording of your question.

The next step is to add a filter to the line where the "Entries" field is listing the xpath. It will look like this: /dfs:myFields/dfs:dataFields/d:SharePointListItem_RW

What you want to do to create the filter is to click the field button to the right of the entries field. In the bottom left of the pop up is a "Filter Data..." button. Hit that and we will get a bit more serious.

In the Filter Data window it will list the Existing filters. It is likely blank unless you have already been messing around with this.

If you hit the "Add" button it will open the "Specify Filter conditions" window.

In that window you will want to set up your filter.

If you want to filter by a text field it is a piece of cake to assemble your query. you fill it in using the dropdowns and get useful data. There is a simple solution if you don't need to be accurate.

You can set your query up to be something like this: First field: click on the select a field or group at the bottom of the list burrow down the created by group to the AccountId string

Middle field: "does not contain"

3rd field: Click "use a formula" find the function "userName()"

click OK on all the windows and your xPath in the "Entries" box for the control will look a little like this: /dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[not(contains(d:Author/pc:Person/pc:AccountId, xdUser:get-UserName()))]

However, this has a problem when Rebecca Smith is trying to find Ro ber Smither's documents it will be a problem because Roberts documents will be filtered out because his User ID will be formatted like this: DOMAIN\RSMITHER which does contain RSMITH which will be the return on Rebecca's username() function.

To fix this we need to grab the user information from the site's user information list, then use that to filter by does not equal.

This is well covered by many blogs. http://www.ilikesharepoint.de/2013/01/infopath-20102013-userinformationlist-query-for-current-logged-in-user/ will work until that link dies, but a google search of "InfoPath user information list" should always get you on the right track for this perennial favorite.

Once you have the user information list back you can build a filter just like above, but instead of does not contain, you change it to "is not equal to" in the middle field and in the 3rd field us the "Select a field or group..." option and burrow into the user information list results and select datafields -> SharePointListItem_RW -> Account

This will leave you witht he xPath in the Entries field of: /dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Author/pc:Person/pc:AccountId[. != xdXDocument:GetDOM("User Information List")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Name]

Depending on your naming conventions and architecture it may be a little different, but I have used this technique extensively and it works well.

许可以下: CC-BY-SA归因
scroll top