Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Build of flow to create a dynamic prioritization column in SharePoint

(1) ShareShare
ReportReport
Posted on by
Dear community,
 
I could need some support in creating a way to add a priority to items in a list in SharePoint. I have a list with 10 items, that needs to be prioritized from 1 to 10. That is surely easy enough. My problem is that if I change the priority of one item (let's say I move No. 1 down to No. 10), then I would really like for the full list of items to update automatically accordingly (moving the old prio No. 2-10 one step up).
 
I am not very trained in Power Automate and if there is a solution through Power Automate, I would highly appreciate screen dumps:-).
 
 
 
  • Chriddle Profile Picture
    Chriddle 7,289 on at
    Build of flow to create a dynamic prioritization column in SharePoint
    The idea is to set the priority of the element to an intermediate priority value and set the indices of the sorted array as new priority values:

     
    Compose
    The array with the initial priorities
     
    Compose-ChangePriority
    The item that changes priority with its new priority value
     
    Select-TmpPriority
    Set the intermediate priority value. Substract 0.1 if the priority goes up, add 0.1 if the priority goes down.
    And convert all priority values to float (needed for the sorting)
     
    From:
    outputs('Compose')
    Map:
    if(
    	equals(
    		outputs('Compose-ChangePriority')['name'],
    		item()['name']
    	),
    	setProperty(
    		item(),
    		'priority',
    		if(
    			less(
    				outputs('Compose-ChangePriority')['priority'],
    				item()['priority']
    			),
    			sub(
    				outputs('Compose-ChangePriority')['priority'],
    				0.1
    			),
    			add(
    				outputs('Compose-ChangePriority')['priority'],
    				0.1
    			)
    		)
    	),
    	setProperty(
    		item(),
    		'priority',
    		float(
    			item()['priority']
    		)
    	)
    )
     
    Select-NewPriority
    Set the new priority to array index+1 of the sorted array.
    From:
    range(0, length(body('Select-TmpPriority')))
    Map:
    setProperty(
    	sort(body('Select-TmpPriority'), 'priority')[item()],
    	'priority',
    	add(item(), 1)
    )
     
  • trice602 Profile Picture
    trice602 11,627 on at
    Build of flow to create a dynamic prioritization column in SharePoint
    Hi,
     
    I haven't tried this specially for your request, but this looks pretty good.  Check this out!
     

    Steps in Power Automate

    1. Trigger the Flow

    • Create a new flow in Power Automate:
      • Trigger: When an item is created or modified.
      • Configure it to point to your SharePoint list.

    2. Initialize Variables

    • Add an Initialize Variable action to store the updated item's ID:

      • Name: UpdatedItemID
      • Type: Integer
      • Value: ID (Dynamic content from the trigger).
    • Add another Initialize Variable action to store the updated item's new priority:

      • Name: NewPriority
      • Type: Integer
      • Value: Priority (Dynamic content from the trigger).

    3. Retrieve All Items in the List

    • Add the Get Items action:
      • Site Address: Your SharePoint site URL.
      • List Name: Your list name.
    • Sort the items by the Priority column to maintain proper order.

    4. Loop Through All Items

    • Add an Apply to each action to loop through all items returned by the Get Items action.

    Inside the loop:

    1. Condition to Skip the Updated Item:

      • Add a Condition:
        • Expression: items('Apply_to_each')?['ID'] is not equal to variables('UpdatedItemID').
      • If the condition is True, proceed.
    2. Determine the New Priority:

      • Add a Condition:

        • Check if the current item's priority is greater than or equal to the new priority:
          • Expression: items('Apply_to_each')?['Priority'] >= variables('NewPriority').
      • If True:

        • Add an Update Item action to increment the priority of the current item:
          • Priority: items('Apply_to_each')?['Priority'] + 1.

    5. Update the Modified Item's Priority

    • Add an Update Item action after the loop:
      • Update the priority of the modified item to its new value (stored in NewPriority).
     

    ------------------------------------------------

     

     

    ⭐ If this was helpful, please like and mark as a verified answer to help others find this too!

     

     

    Always glad to help! 💯💯💯💯💯

     

    Tom

     

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard