this.context.listView.columns is an empty array
Category
- [x] Bug
Describe the bug
this.context.listView.columns in a Command Set is always an empty array. This has been working fine until today.
Steps to reproduce
Create a new command set extension and log this.context.listView.columns.
Expected behavior
this.context.listView.columns in Command Set provides a list columns in the current view
Environment details (development & target environment)
Office 365 The issue occurs in target and standard release.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Hi,
I debug in my environment, I could get it in OnExecute while not in onListViewUpdated.

Lee Microsoft SharePoint Community Support
Thanks Lee. OnExecute is too late for me. Until yesterday, this worked perfectly in OnListViewUpdated. Hundreds of customers use this app and suddenly it stops working...
At our company we have the excact same issue in a commandbar extension.
In the onInit of the commandset class:
export default class ItemEditorCommandSet extends BaseListViewCommandSet<ICompanyCommandSetProperties>
[...]
@override
public async onInit(): Promise<void>
{
const columns = this.context.listView.columns
}
This suddenly returns an emprty array, while functionality in our case depends on it, while it has worked just a couple of days ago.
Our company is plus-size, and more than a thousend people depend on this.
Also onExcecute is too late for us, we need to decide wheter to show the command or not, this is only possible in onInit
The exact same issue has occured in 2017: Command Set Extension: this.context.listView.columns is empty array #867
Please let us know what the solution is to fix this.
@florianwachter have you constructed a workaround?
@69mustang302: I now use the viewId from this.context.pageContext.legacyPageContext.viewId to get the columns using the REST api instead. Hope this helps.
@florianwachter thank you, that helps! As a workaround i indeed intend to make a rest query to figure out wheter or not to show my commandbuttons. I hoped for another alternative though, since this is far from ideal because this code will run on any lists in your site, and this will lead to unnecessary traffic and performance impact on lists. So lets hope for a quick resolution by @andrewconnell
@69mustang302 why me?
@andrewconnell ha, because you added the labels, i assumed you could help ;)
@69mustang302 :) I help manage/triage the list. SPFx is my domain & I answer questions where I can, but I can't "fix" anything. I don't work for Microsoft... this is one of my community contributions and giving back to the SP dev community.
Thanks for helping, ofcourse it's greatly appreciated!
Missed this due to some metadata hiccups. This has been fixed (it was a duplicate of #867 )
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues