Description
I used m365 spo page control list to get a list of controls (web parts) on my modern page.
The result was a set of 2 controls.
I then used m365 spo page control get to get more details of one of these controls, using the ID from the result of first command.
I then got an error that the control with specified ID can't be found
Steps to reproduce
Use above two commands on any modern page to try and find details on a control.
Expected result
I think it should be possible to use the ID's from the list command to get details using the get command.
Actual result
Controls with ID can't be found.
Environment
macOS Big Sur 11.4, zsh, v3.13.0
Solution
I've looked into the code and think I know what's wrong:
The list command overwrites the actual control ID with the ID of the web part, but the get command expects the control ID and not the web part ID.
It happens in these lines (52-63) of src/m365/spo/commands/page/page-control-list.ts:
const controls: any[] = canvasData.filter(c => c.position).map(c => {
return {
controlType: c.controlType,
order: c.position.sectionIndex,
id: c.id, // <== This is where the correct ID is set...
controlData: {
...c
},
...c.webPartData || {}, // <== ... but here it's overwritten because this object has an ID too, but web part ID in this case
type: SpoPageControlListCommand.getControlTypeDisplayName(c.controlType || 0)
};
});
Description
I used
m365 spo page control listto get a list of controls (web parts) on my modern page.The result was a set of 2 controls.
I then used
m365 spo page control getto get more details of one of these controls, using the ID from the result of first command.I then got an error that the control with specified ID can't be found
Steps to reproduce
Use above two commands on any modern page to try and find details on a control.
Expected result
I think it should be possible to use the ID's from the list command to get details using the get command.
Actual result
Controls with ID can't be found.
Environment
macOS Big Sur 11.4, zsh, v3.13.0
Solution
I've looked into the code and think I know what's wrong:
The list command overwrites the actual control ID with the ID of the web part, but the get command expects the control ID and not the web part ID.
It happens in these lines (52-63) of src/m365/spo/commands/page/page-control-list.ts: