0

We have list with user email id detail and other project related detail. When the user logs in he should only see list items where his email id exist.

Filter List view (with email id) based on current user email id

0

Option 1: If you can change email id field of list with People and group, then it would serve your purpose without any customization or scripting on page. You can filter view by [Current User]

Option 2: You can use jslink to remove or delete rows where email id does not match with current user.

(function () {
 function listPreRender(renderCtx) {
var rows = renderCtx.ListData.Row;
 var excludeRows=[];
for(var i = rows.length - 1; i >= 0; i--) {
    var emailid = rows[i]["Email Id"];
      if (emailid.indexOf('currentUserEmailID') < 0)
      {
        excludeRows.push(i);//row idexes to be excluded
      }
 }
 for(var i = excludeRows.length - 1; i >= 0; i--) {
    var rowIdx = excludeRows[i];  //get row index to exclude 
    rows.splice(rowIdx, 1);  //delete List View Row
    renderCtx.ListData.LastRow = rows.length;  //update ListData.LastRow property
 }
}
function registerListRenderer()
{
var context = {};
context.Templates = {};
context.OnPreRender = listPreRender;
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(context);
} 
ExecuteOrDelayUntilScriptLoaded(registerListRenderer, 'clienttemplates.js');
})();
0

Below are 2 options

  1. Use Connected Filter webpart and list view webpart to do the same. Keep email id of user in querystring and use it in webpart to filter data.

https://support.office.com/en-us/article/Connect-a-Query-String-URL-Filter-Web-Part-to-another-Web-Part-8fd0107f-4889-451b-a7f7-d1996e12a8d1?ui=en-US&rs=en-US&ad=US

  1. Create/write custom code to retrive data from list and show it to user, retrieve email from query string and pass it in CAML query to get only required data and display it on screen.If the email id is same as in active directory which is being stored in list, you can get users'e email id from user properties.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.