
# SharePoint Template Folder Configuration Example

This example shows how to configure the SharePointFolderInputWidget to support template folder creation.

## Type Schema Configuration

Add this configuration to your type schema to enable the template functionality:

```json
{
  "type": "string",
  "title": "Project Folder",
  "description": "Select or create a project folder from template",
  "x-type-schema": {
    "inputWidget": "SharePointFolderInputWidget",
    "inputWidgetConfiguration": {
      "sharepointTemplateUsage": {
        "sharepointTemplateFolder": {
          "driveId": "b!template-drive-id-here",
          "folderId": "template-folder-id-here"
        },
        "newSharepointFolderLocation": {
          "driveId": "b!target-drive-id-here",
          "folderId": "parent-folder-id-here"
        },
        "newSharepointFolderName": "#{show address.street} #{show address.streetNumber} #{show address.zip} #{show address.city}"
      }
    }
  }
}
```

## Configuration Properties

### `sharepointTemplateFolder`
The source template folder to copy from:
- `driveId`: SharePoint drive ID (starts with `b!`)
- `folderId`: (Optional) Folder ID within the drive. If omitted, uses root folder

### `newSharepointFolderLocation`  
The target location where new folders will be created:
- `driveId`: SharePoint drive ID where new folders should be created
- `folderId`: (Optional) Parent folder ID. If omitted, creates in root

### `newSharepointFolderName`
The name for the new folder with variable substitution support:
- Use `${variable}` syntax to insert form data
- Supports nested properties like `${address.street}`
- Variables are resolved from the current form data

## UI Behavior

When all three properties are configured:
1. The widget shows both "Select Folder" and "Use Template" buttons
2. Clicking "Use Template" creates a new folder with the specified name
3. Progress feedback shows folder creation and content copying
4. On success, the new folder is automatically selected
5. Error handling provides user-friendly messages

## Variable Substitution Examples

```javascript
// Form data example:
{
  "address": {
    "street": "Main Street", 
    "streetNumber": "123",
    "zip": "12345",
    "city": "Springfield"
  },
  "projectName": "New Development"
}

// Template name: "Real Estate #{show address.street} #{show address.streetNumber} #{show address.zip} #{show address.city}"
// Result: "Real Estate Main Street 123 12345 Springfield"

// Template name: "Project #{show projectName} - #{show address.city}"  
// Result: "Project New Development - Springfield"
```

## Notes

- Template functionality only appears when all three configuration properties are provided
- The widget maintains backward compatibility - existing configurations continue to work unchanged
- Uses user-delegated permissions that don't require admin consent for most SharePoint operations
- Progress feedback includes percentage completion and user-friendly status messages
