I have list with multiple views , i want to add button in each view to show the total numbers assigned to the current user

is it possible?

  • what do you mean with assigned to ? are you have task list ? do you mean the current user the login user? please add more details to can help you faster !! May 5, 2017 at 12:53
  • you can apply filter on the view as created by [Me]
    – Sunil Sahu
    May 5, 2017 at 13:50
  • Why a button? Better UX is to highlight the assigned-to me Items in the current View, needs some JavaScript and the WYSIWYG CSR (Client Side Rendering) Cisar Editor (Chrome Extension) May 5, 2017 at 17:22

2 Answers 2


Whatever you are using task list or custom list, I don't think you need to use javascript to achieve your requirements also you can't add a button to each view simply as OOTB. you will need to customize it.

So my suggestions get the total items based on the login user as the following:

  • Open your list > select your view > from the above ribbon click on modify view.
  • At filter section > select the assigned to field equal to [me] enter image description here

  • At total section > Count with any column as you need.

enter image description here


enter image description here

Regarding other views you can repeat the above steps,

Regarding new views you can create a view from existing view that has the same configuration and starts from it :)


Use the WYSIWIG Cisar editor

Create a CSR - Client Side Rendering file that highlights (green) the Items Assigned To the current user

This is all CSR code required:

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function () {

  function assignedToMe(ctx){
    if (user = ctx.CurrentItem.AssignedTo[0]) {
        color = (_spPageContextInfo.userId == user.id) ? 'lightgreen' : 'inherit';
        return String.format("<span style='background:{0}'>{1}</span>", color, user.value);
    return "";

  function init() {
      Templates: {
        Fields: {
          "AssignedTo": {
            View: assignedToMe

    SPClientTemplates.Utility.ReplaceUrlTokens("~siteCollection/Style Library/myfile.js")
    , init);

JavaScript Notes:

  • user and color variables are not declared, so JS hoists them to local variables within the function

  • the user.id is a string, while the userId is Number, comparing with == works fine, while comparing with === will not

  • String.format is provided by SharePoint SP.js code, it can do lots more
    see: Changing date format using javascript

It gets you colors in the View


  • you do have to add the file to the JSLink definition of every view (open Cisar in every View and link your file, Cisar creates the JSLinks for you)

  • If you execute the JS file as UserCustomAction (or load it in the MasterPage), it will be applied to every AssignedTo field in every View

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.