You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power Automate技术问询:如何为SharePoint列表中每批来自ATSUB邮件的项生成ATSUB#与ATT#自动编号

Hey there! Let's walk through how to build this automatic numbering system for your SharePoint list, tailored to your ATSUB email and attachment workflow.

Core Requirements Recap

First, let's make sure we're aligned on what you need:

  • A unique ATSUB#XXXX (4-digit sequential number) for each incoming ATSUB email with PDF attachments
  • One SharePoint list item per PDF attachment, sharing the same ATSUB# as the parent email
  • Sequential sub-numbering for attachments in the same email: ATT#XXXX-YY (YY is a 2-digit number starting at 01)
  • Your list already has columns: ATSUB#, ATT#, Email ID, Attachment ID

This is the most reliable way to handle email triggers, number generation, and list item creation. Here's a step-by-step breakdown:

Step 1: Set Up the Email Trigger

  1. Create a new Automated cloud flow in Power Automate
  2. Choose the trigger: When a new email arrives (V3) (using the Office 365 Outlook connector)
  3. Configure trigger filters to target only your ATSUB emails:
    • Set Subject contains to ATSUB
    • Check Has attachments to Yes
    • (Optional) Add a filter for Attachment name ends with .pdf to pre-filter attachments

Step 2: Generate the Next ATSUB#

We need to pull the highest existing ATSUB# from your list, increment it, and format it correctly:

  1. Add a Get items action (SharePoint connector) pointing to your list
    • Set Sort by to ATSUB#, Sort order to Descending, and Top count to 1 (this grabs the latest record with the highest ATSUB number)
  2. Initialize a string variable named NewATSUBID
  3. Add a Condition action to check if the Get items result is empty (meaning your list has no records yet):
    • If true (empty list): Set NewATSUBID to ATSUB#0001
    • If false: Use this expression to increment and format the number:
      concat('ATSUB#', formatNumber(add(int(substring(body('Get_items')?['value'][0]?['ATSUB#'], 6, 4)), 1), '0000'))
      
      How this works: It extracts the 4-digit number from the existing ATSUB#, converts it to an integer, adds 1, formats it back to a 4-digit string with leading zeros, then appends the ATSUB# prefix.

Step 3: Process Attachments & Create List Items

For each PDF attachment in the email, create a list item with the correct ATT#:

  1. Initialize an integer variable named AttachmentCounter with a default value of 1 (this tracks the sub-number for attachments in the current email)
  2. Add an Apply to each action, selecting the Attachments output from your email trigger
  3. Inside the loop, add a Condition to check if the current attachment's Name ends with .pdf (to skip non-PDF attachments)
    • If true:
      1. Generate the ATT# using this expression:
        concat('ATT#', substring(variables('NewATSUBID'), 6, 4), '-', formatNumber(variables('AttachmentCounter'), '00'))
        
      2. Add a Create item action (SharePoint connector) and populate the fields:
        • DATE: Use the email's Received time
        • ATSUB#: Select the NewATSUBID variable
        • ATT#: Paste the ATT# expression you just created
        • Email ID: Use the email's ID (from the trigger output)
        • Attachment ID: Use the current attachment's ID (from the loop item)
      3. Add an Increment variable action to increase AttachmentCounter by 1 (so the next attachment gets the next sub-number)

Step 4: Test & Refine

  • Send a test ATSUB email with 1 or more PDF attachments to verify the flow triggers correctly and creates the right list items
  • If you have historical ATSUB emails to process, you can use the Manually trigger a flow option and select existing emails to backfill your list

Key Notes

  • Make sure your Power Automate account has permissions to read emails from your Outlook inbox and edit the SharePoint list
  • Set the ATSUB# column in SharePoint to Unique to prevent duplicate numbers (this acts as a safety check if the flow runs unexpectedly)
  • If your list has a large number of existing records, double-check that the Get items action correctly pulls the highest ATSUB# (you might need to adjust the filter if you have older entries with non-standard formatting)

内容的提问来源于stack exchange,提问作者VeeEss

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 16:22:30