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

%3CLINGO-SUB%20id%3D%22lingo-sub-917463%22%20slang%3D%22en-US%22%3ESPFX%20Extension%20Issue%20%3A%20ListViewCommandSet%20-%20onExecute%20parameters%20getting%20wrong%20selectedRows%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-917463%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20SPFX%2C%20if%20we%20create%20extension%20ContextMenu%20%2F%20CommandBar%20using%2C%3C%2FP%3E%3CP%3Econtent%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fdev%2Fspfx%2Fextensions%2Fget-started%2Fbuilding-simple-cmdset-with-dialog-api%23feedback%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBuild%20your%20first%20ListView%20Command%20Set%20extension%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20first%20time%20selection%20of%20document%20%2F%20item%20selected%20row%20we%20will%20get%20value%20for%20event.selectedRows%5B0%5D.getValueByName(%22ID%22)%3C%2FP%3E%3CP%3Ebut%2C%20if%20you%20deselect%20the%20row%20and%20select%20other%20document%20%2F%20item%20row%20then%20value%20for%26nbsp%3Bevent.selectedRows%5B0%5D.getValueByName(%22ID%22)%20not%20getting%20updated%20and%20gives%20previously%20selected%20value%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

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
Highlighted

@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