Step-by-Step Flow Implementation
Step 1: Create the Flow Trigger
Trigger: "When a file is created (properties only)"
- Site Address: Select your SharePoint site
- Library Name: Select the document library containing your PDFs
- Folder: (Optional) Specify folder if needed
Step 2: Get File Content
Action: "Get file content"
- Site Address: Use dynamic content from trigger
- File Identifier: Use "Identifier" from trigger
Step 3: AI Builder - Extract Information
Action: "Extract information from documents"
- Document: Use "File content" from previous step
- AI Model: Select your pre-built AI Builder model
- This will extract: Name, Title, Phone, Email, Position, Working place, State, Date of contract signed
Step 4: Initialize Variables for Data Cleaning
Variable 1: CleanName
Name: CleanName
Type: String
Value: (will be set in next step)
Variable 2: CleanTitle
Name: CleanTitle
Type: String
Value: (will be set in next step)
Variable 3: CleanWorkingPlace
Name: CleanWorkingPlace
Type: String
Value: (will be set in next step)
Step 5: Clean and Format Extracted Data
Action: Set Variable (CleanName)
Name: CleanName
Value: replace(replace(replace(replace(replace(first(body('Extract_information_from_documents')?['documents'])?['fields']?['Name']?['values'])?['text'], ' ', '_'), '/', '_'), '\', '_'), ':', '_'), '.', '_')
Action: Set Variable (CleanTitle)
Name: CleanTitle
Value: replace(replace(replace(replace(replace(first(body('Extract_information_from_documents')?['documents'])?['fields']?['Title']?['values'])?['text'], ' ', '_'), '/', '_'), '\', '_'), ':', '_'), '.', '_')
Action: Set Variable (CleanWorkingPlace)
Name: CleanWorkingPlace Value: replace(replace(replace(replace(replace(first(body('Extract_information_from_documents')?['documents'])?['fields']?['Working place']?['values'])?['text'], ' ', '_'), '/', '_'), '\', '_'), ':', '_'), '.', '_')
Step 6: Create New File Name
Action: Initialize Variable
Name: NewFileName
Type: String
Value: concat(variables('CleanName'), '_', variables('CleanTitle'), '_', variables('CleanWorkingPlace'), '.pdf')
Step 7: Handle Empty Fields (Optional but Recommended)
Action: Condition
If: and(not(empty(variables('CleanName'))), not(empty(variables('CleanTitle'))), not(empty(variables('CleanWorkingPlace'))))
Yes Branch: Continue with renaming
No Branch: Handle missing data (see Step 9)
Step 8: Rename the File
Action: "Update file properties"
- Site Address: Same as trigger
- Library Name: Same as trigger
- Id: Use "Identifier" from trigger
- Title: Use
variables('NewFileName')
Alternative Method (If above doesn't work):
Action: "Copy file"
- Current Site Address: Original location
- Current Library Name: Original library
- Current File Identifier: From trigger
- Destination Site Address: Same location
- Destination Library Name: Same library
- Destination File Name:
variables('NewFileName')
Then add:
Action: "Delete file"
- Site Address: Original location
- Library Name: Original library
- File Identifier: From trigger
Step 9: Handle Missing Data (No Branch)
Action: Compose
Value: Default_Document_@{formatDateTime(utcNow(), 'yyyyMMdd_HHmmss')}.pdf
Action: Update file properties
- Use the composed default name
If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
Regards,
Riyaz