SPFX Extension Issue : ListViewCommandSet - onExecute parameters getting wrong selectedRows value

Copper Contributor

In SPFX, if we create extension ContextMenu / CommandBar using,

content: Build your first ListView Command Set extension

 

For first time selection of document / item selected row we will get value for event.selectedRows[0].getValueByName("ID")

but, if you deselect the row and select other document / item row then value for event.selectedRows[0].getValueByName("ID") not getting updated and gives previously selected value

1 Reply

@Mangesh_Rane ,

 

I was able to replicate your issue. I ran into the same issue while I was developing my extension.

 

If the extension location is at ContextMenu, there seems to be a bug. "onListViewUpdated" event is not firing whenever you selecting and deselecting the items. So the "event" parameter is still holding the old values. Try to move the location to CommandBar.

 

You might need to update the location element in the following locations

  1. \sharepoint\assets\ClientSideInstance.xml
  2. \sharepoint\assets\elements.xml
  3. \config\serve.json

Before

Location="ClientSideExtension.ListViewCommandSet.ContextMenu"

 

After

Location="ClientSideExtension.ListViewCommandSet.CommandBar"
 
Good luck! Give it a try!
 
Best,
Susheel Dakoju