3

so I know in the view editor one can add the option of filtering by [me]. My question, is is there any way to do this in the URL and not the view?

I would like to keep the standard allitems.aspx, but add a filter like such:
?&FilterField1=Editor&FilterValue1=[Me]

Now, I tested this and it doesn't work, it filters by the literal value of "[me]", which we have no users with that name (obviously).

2
  • I think no. Why are you trying to do that? Perhaps there is another approach Commented Jul 20, 2016 at 16:25
  • I am trying to work on parameter based pages where we load in different document libraries, each with the same filter, based on the URL parameters Commented Jul 20, 2016 at 18:09

1 Answer 1

3

Using JSOM you can find the current user login and create the View URL dynamically.

var clientContext = new SP.ClientContext.get_current();
var oWeb = clientContext.get_web();
var currentUser = oWeb.get_currentUser();
clientContext.load(currentUser);
clientContext.executeQueryAsync(function() {
    //currentUser.get_loginName();
    //currentUser.get_id();
}, function(sender, args) {
    alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
});
1
  • is the .get_loginName() function what returns the name i should filter by? Commented Jul 20, 2016 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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