- 
                Notifications
    You must be signed in to change notification settings 
- Fork 366
New command: spo list defaultvalue get. Closes #6535 #6967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| Thank you for opening the PR 👏 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new command spo list defaultvalue get to retrieve a specific default column value from a SharePoint document library. The command supports retrieval by list ID, title, or URL, and can optionally filter by folder location.
Key Changes:
- Added new command to retrieve default column values from a document library
- Implemented XML parsing for SharePoint's client_LocationBasedDefaults.html file
- Added comprehensive test coverage with multiple scenarios including error handling
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description | 
|---|---|
| src/m365/spo/commands/list/list-defaultvalue-get.ts | Core command implementation with XML parsing and API integration | 
| src/m365/spo/commands/list/list-defaultvalue-get.spec.ts | Comprehensive test suite covering all command scenarios | 
| src/m365/spo/commands.ts | Command registration in the commands list | 
| docs/src/config/sidebars.ts | Documentation navigation entry | 
| docs/docs/cmd/spo/list/list-defaultvalue-get.mdx | User-facing command documentation | 
| .devproxy/api-specs/sharepoint.yaml | API endpoint specifications for dev proxy | 
| interface DefaultColumnValue { | ||
| fieldName: string; | ||
| fieldValue: string; | ||
| folderUrl: string | 
    
      
    
      Copilot
AI
    
    
    
      Oct 24, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing semicolon at the end of the property declaration.
| folderUrl: string | |
| folderUrl: string; | 
| headers: { | ||
| accept: 'application/json;odata=nometadata' | ||
| }, | ||
| responseType: 'json' | 
    
      
    
      Copilot
AI
    
    
    
      Oct 24, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The responseType is set to 'json' (line 152) but the endpoint returns XML content. This will cause the response to be incorrectly parsed. Change responseType to 'text' since the content is XML.
| responseType: 'json' | |
| responseType: 'text' | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅Tested locally works perfectly
@Ateina amaizing work 😍
I don't have much to add. I only added two comments which will improve the reusability of our codebase. Please consider them before we proceed.
Copilot also noticed some minor things we could fixup.
Other than that seems very solid 👍
You Rock 🤩
| return defaultValuesXml; | ||
| } | ||
|  | ||
| private convertXmlToJson(xml: string): DefaultColumnValue[] { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar method is already present in defaultvalue list command
cli-microsoft365/src/m365/spo/commands/list/list-defaultvalue-list.ts
Lines 149 to 173 in 582b84c
| private convertXmlToJson(xml: string): DefaultColumnValue[] { | |
| const results: DefaultColumnValue[] = []; | |
| const parser = new DOMParser(); | |
| const doc = parser.parseFromString(xml, 'application/xml'); | |
| const folderLinks = doc.getElementsByTagName('a'); | |
| for (let i = 0; i < folderLinks.length; i++) { | |
| const folderUrl = folderLinks[i].getAttribute('href')!; | |
| const defaultValues = folderLinks[i].getElementsByTagName('DefaultValue'); | |
| for (let j = 0; j < defaultValues.length; j++) { | |
| const fieldName = defaultValues[j].getAttribute('FieldName')!; | |
| const fieldValue = defaultValues[j].textContent!; | |
| results.push({ | |
| fieldName: fieldName, | |
| fieldValue: fieldValue, | |
| folderUrl: decodeURIComponent(folderUrl) | |
| }); | |
| } | |
| } | |
| return results; | |
| } | 
I suggest we extract those and move as a new uti method to utils/formatting.ts to avoid code duplicates and improve our codebase a little
| import request, { CliRequestOptions } from '../../../../request.js'; | ||
| import { formatting } from '../../../../utils/formatting.js'; | ||
|  | ||
| interface DefaultColumnValue { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in this case we already have similar interface here
cli-microsoft365/src/m365/spo/commands/list/list-defaultvalue-list.ts
Lines 13 to 17 in 582b84c
| interface DefaultColumnValue { | |
| fieldName: string; | |
| fieldValue: string; | |
| folderUrl: string | |
| } | 
lets extract this model interface to a separate file and reuse in both places 👍
Closes #6535