Forum Discussion

Spawn10's avatar
Spawn10
Copper Contributor
Nov 26, 2023
Solved

How do I grab the last user information entered into a peoples column that allows multiple entries?

I have a list I am using the gallery view on. Each item in the list is an activity that the users might want to attend, so I have a people's column called 'Guests' that holds multiple users. For each item in the list, I have a button displayed on each gallery tile that users can click on to add themselves to the activity they like...I did this using JSON formatting.

{
	"elmType": "div"
	"attributes": {
		"Class": "sp-card-lastTextColumnContainer"
	},
	"style": {
		"display": "if(Number([$TotalGuestAllowed]) > 0, 'block', 'none')"
	},
	"children": [
		{
			"elmType": "p",
			"attributes": {
				"Class" : "ms-fontColor-neutralSecondary sp-card-label"
			},
			"txtContent": "RSVP"		
		},
		{
			"elmType": "p",
			"attributes": {
				"Class": "ms-fontColor-neutralPrimary sp-card-content"
			},
			"children": [
				{
					"elmType": "button",
					"customRowAction": {
						"action": "setValue",
						"actionInput": {
							"Guests": "=appendTo([$Guests], me)",
							"TotalGuestAllowed": "=[$TotalGuestAllowed] -1"
						}
					}
				}
			]
		}
	
	]
	
}

Each time a user clicks on this button, their name is added to the guest column (which is the people's column that allows multiple entries).  

Is there a way to grab the name of the last entry into this "Guests" column, after a new user clicks the button? I want to be able to send some information to only the last user entered into this guest column.

  • Spawn10 Check below JSON and example which will help you with your final solution. I am fetching the name of last selected user from people column using JSON formatting: 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "=if(length([$GuestUsers])==1,[$GuestUsers.title],substring(join([$GuestUsers.title],'||'),lastIndexOf(join([$GuestUsers.title],'||'),'||')+2,indexOf(join([$GuestUsers.title],'||') + '^', '^')))"
    }

     

    Output

    Where GuestUsers is the name of multiple selection allowed people column. You can get the exact internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

     

    Similar threadJSON Formatting to show last item select from multi selection choice field  


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

1 Reply

  • Spawn10 Check below JSON and example which will help you with your final solution. I am fetching the name of last selected user from people column using JSON formatting: 

     

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
      "elmType": "div",
      "txtContent": "=if(length([$GuestUsers])==1,[$GuestUsers.title],substring(join([$GuestUsers.title],'||'),lastIndexOf(join([$GuestUsers.title],'||'),'||')+2,indexOf(join([$GuestUsers.title],'||') + '^', '^')))"
    }

     

    Output

    Where GuestUsers is the name of multiple selection allowed people column. You can get the exact internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

     

    Similar threadJSON Formatting to show last item select from multi selection choice field  


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

Resources