Answered by:
URL Link in item list to other list using filter FilterValue1 People (Создание ссылки в элементе на другой список с использованием фильтра по пользователю)

Question
-
День добрый.
подскажите как решить такую задачу:
в элементе создаю ссылку на другой список с использованием фильтрации.
фильтровать по полю с типом текст получается хорошо. рабочий пример:
="<a href='http://srv-spwfe/prints/_layouts/15/start.aspx#/Lists/List1/AllItems.aspx?View={A8F46D88-4B41-41C5-A62B-D0B2D856687D}&FilterField1=model&FilterValue1="&Модель&"'>View</a>"
а если в фильтре указывать ФИО (поле с типом пользователь) , ФИО на русском . идут проблемы с кодировкой - фильтр не работает.
как можно сделать ссылку с фильтром по полю с типом пользователь?
Спасибо.
- Edited by Больных Сергей Thursday, November 14, 2019 8:18 AM
Answers
-
Hi Больных Сергей,
IE does not recognize the URL correctly. We can encode the URL in an Html file via JavaScript.
<!DOCTYPE html> <html> <head> <title>Page Title</title> <meta charset="utf-8"> <script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { var oldurl= $('a').attr('href'); $('a').removeAttr('href'); $('a').attr('href', encodeURI(encodeURI(oldurl))); alert($('a').attr('href')); }); </script> </head> <body> <h1>This is a Link</h1> <a target="_blank" href='http://{site}/_layouts/15/start.aspx#/Lists/anotherlist/AllItems.aspx#InplviewHashf2e939d0-9537-4e38-aaa9-9c4ab88daa23=SortField=s6pg-SortDir=Asc-FilterField1=s6pg-FilterValue1=Больных ech. Сергей Николаевич'>View-filter</a> </body> </html>
Result:
Best Regards,
Baker Kong
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.- Edited by Baker_KongMicrosoft contingent staff Tuesday, November 19, 2019 8:36 AM
- Marked as answer by Больных Сергей Tuesday, November 19, 2019 12:51 PM
-
Hello. Thanks.
Yes, it helped me -
encodeURIComponent()
And also helped me by Vladimir Kaplin with his tips and blog. Thank you!
https://kaplin-vladimir.blogspot.com/2015/12/people-picker.html
<script type="text/javascript" src="...../Style Library/jquery.js"></script> <script type="text/javascript"> _spBodyOnLoadFunctionNames.push("WorkingWithFields"); function WorkingWithFields() { addEventToPP("Workmans"); } function addEventToPP(fieldId) { function setTitle() { var title = jQuery("[id^='urlencod']"); title.attr("disabled", "disabled"); var strFieldId = jQuery("[title= '" + fieldId +"']").attr("id"); //console.log(strFieldId) var field = SPClientPeoplePicker.SPClientPeoplePickerDict[strFieldId]; //console.log(field) field.OnUserResolvedClientScript = function (peoplePickerId, selectedUsersInfo) { if (selectedUsersInfo.length > 0) { if (selectedUsersInfo[0].IsResolved) { //console.log(selectedUsersInfo[0]); if(selectedUsersInfo[0].DisplayText) { var urlenc = encodeURIComponent(selectedUsersInfo[0].DisplayText) title.val(urlenc); title.prop("disabled", false); } } } else { title.val(""); // cleaning title title.attr("disabled", "disabled"); // disabled Title } } } setTitle(); } </script>
The task is a little deeper, get a full name of a person in Cyrillic (input type peoplepicker) and convert it to the correct form to form a URL.
Now I got a full name in the right encoding that all browsers understand correctly. And I am ready to generate a url using filtering
- Marked as answer by Больных Сергей Tuesday, November 19, 2019 12:52 PM
All replies
-
Hi Больных Сергей
I created a generic list on SharePoint 2013 and tested the following URL. Luckily it could filter items by user column.
URL :
{page}/AllItems.aspx?FilterField1={user filed name}&FilterValue1={username}
Result:
Best Regards,
Baker Kong
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019. -
проблема состоит в том что - передаются русские ФИО в плохой кодировке.
вот ссылка:
http://srv-spwfe/orgtehk/Lists/List/AllItems.aspx#InplviewHash36815dce-4fb7-4b9c-bdbb-4f8294e73759=FilterField1%3D%255Fx041e%255F%255Fx0442%255F%255Fx0432%255F%255Fx0435%255F%255Fx04-FilterValue1="БольныхСергей Николаевич" (без ковычек тоже пробовал) -
Hi Больных Сергей,
Could you please repeat the above info using English? As this forum only support English and we can hardly understand this issue correctly. Thanks for your understanding!
Best Regards,
Baker Kong
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019. -
Ok. sorry
I insert a column value in Cyrillic (FilterValue1) into the URL and as a result the filtering is not working correctly because Cyrillic is not encoded correctly. Watch the photo in the post above
using Sharepoint 2013 rus
- Edited by Больных Сергей Friday, November 15, 2019 10:04 AM
-
Hi Больных Сергей,
I created a user with a non-English name. However in the test it could be filtered successfully.
Can you please have a try with following pattern? you can encode/decode the URL here.
?FilterField1={field name}&FilterValue1={Больных}
Best Regards,
Baker Kong
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019. -
This link URL
http://srv-spwfe/orgtehk/_layouts/15/start.aspx#/SitePages/testlist.aspx?View={8397D06F-56C3-43FF-A022-200B274EA42E}&FilterField1=%5Fx041e%5F%5Fx0442%5F%5Fx0432%5F%5Fx0435%5F%5Fx04&FilterValue1=Больных&InitialTabId=Ribbon%2ERead&VisibilityContext=WSSTabPersistence
result
A link that configures Sharepoint itself by filter to a full name :
http://srv-spwfe/orgtehk/_layouts/15/start.aspx#/SitePages/testlist.aspx?View={8397D06F-56C3-43FF-A022-200B274EA42E}&FilterField1=%5Fx041e%5F%5Fx0442%5F%5Fx0432%5F%5Fx0435%5F%5Fx04&FilterValue1=%D0%91%D0%BE%D0%BB%D1%8C%D0%BD%D1%8B%D1%85%20%D0%A1%D0%B5%D1%80%D0%B3%D0%B5%D0%B9%20%D0%9D%D0%B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%B8%D1%87&InitialTabId=Ribbon%2ERead&VisibilityContext=WSSTabPersistence
-
-
Hi Больных Сергей,
IE does not recognize the URL correctly. We can encode the URL in an Html file via JavaScript.
<!DOCTYPE html> <html> <head> <title>Page Title</title> <meta charset="utf-8"> <script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { var oldurl= $('a').attr('href'); $('a').removeAttr('href'); $('a').attr('href', encodeURI(encodeURI(oldurl))); alert($('a').attr('href')); }); </script> </head> <body> <h1>This is a Link</h1> <a target="_blank" href='http://{site}/_layouts/15/start.aspx#/Lists/anotherlist/AllItems.aspx#InplviewHashf2e939d0-9537-4e38-aaa9-9c4ab88daa23=SortField=s6pg-SortDir=Asc-FilterField1=s6pg-FilterValue1=Больных ech. Сергей Николаевич'>View-filter</a> </body> </html>
Result:
Best Regards,
Baker Kong
Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.
SharePoint Server 2019 has been released, you can click here to download it.
Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.- Edited by Baker_KongMicrosoft contingent staff Tuesday, November 19, 2019 8:36 AM
- Marked as answer by Больных Сергей Tuesday, November 19, 2019 12:51 PM
-
Hello. Thanks.
Yes, it helped me -
encodeURIComponent()
And also helped me by Vladimir Kaplin with his tips and blog. Thank you!
https://kaplin-vladimir.blogspot.com/2015/12/people-picker.html
<script type="text/javascript" src="...../Style Library/jquery.js"></script> <script type="text/javascript"> _spBodyOnLoadFunctionNames.push("WorkingWithFields"); function WorkingWithFields() { addEventToPP("Workmans"); } function addEventToPP(fieldId) { function setTitle() { var title = jQuery("[id^='urlencod']"); title.attr("disabled", "disabled"); var strFieldId = jQuery("[title= '" + fieldId +"']").attr("id"); //console.log(strFieldId) var field = SPClientPeoplePicker.SPClientPeoplePickerDict[strFieldId]; //console.log(field) field.OnUserResolvedClientScript = function (peoplePickerId, selectedUsersInfo) { if (selectedUsersInfo.length > 0) { if (selectedUsersInfo[0].IsResolved) { //console.log(selectedUsersInfo[0]); if(selectedUsersInfo[0].DisplayText) { var urlenc = encodeURIComponent(selectedUsersInfo[0].DisplayText) title.val(urlenc); title.prop("disabled", false); } } } else { title.val(""); // cleaning title title.attr("disabled", "disabled"); // disabled Title } } } setTitle(); } </script>
The task is a little deeper, get a full name of a person in Cyrillic (input type peoplepicker) and convert it to the correct form to form a URL.
Now I got a full name in the right encoding that all browsers understand correctly. And I am ready to generate a url using filtering
- Marked as answer by Больных Сергей Tuesday, November 19, 2019 12:52 PM