web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Cancel Pending Teams A...
Power Automate
Suggested Answer

Cancel Pending Teams Approval Flow

(0) ShareShare
ReportReport
Posted on by 42
Hello,
I have a model-driven app in one environment and my teams approval requests are in a different environment. In order to get my approvals to work properly, I have done the following:
  • Environment #1 = Flow Part 1A - Approval Flow is triggered from a CE Opportunity and all the details are saved to a SharePoint list
  • Environment #2 = Flow Part 2A - When an item is created in the SharePoint list, it creates a Teams Approval. The result (approve/reject) updates the SharePoint item
  • Environment #2 = Flow Part 2B - When an item is modified in the SharePoint list, it checks if second level of approval is required. Flow cancels if not required but if it is the Teams Approval is created and the result updates the SharePoint item
  • Environment #1 = Flow Part 3 - When an item is modified in the SharePoint list, it checks if all levels of approval have been completed. The details (approve/reject) from the SharePoint list are saved to CE Opportunity
This process works but I need to be able to cancel pending Teams Approvals when the CE Opportunity is updated with a value that no longer requires the approval. Here is what I have so far:
  • Environment #1 = Flow Part 1B  
    • If CE Opportunity has an Approval in Pending Status but trigger is FALSE, update Approval from Pending to Cancelled
    • Get items from SharePoint list, where Title column = Opportunity Number
    • Compose: first(body('Get_items')['value'])['Title']
    • Update SharePoint Item to Cancelled
    • ISSUE #1: first time this flow runs, it fails with this error message: Action 'Compose' failed: Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language expression 'first(body('Get_items')['value'])['Title']' cannot be evaluated because property 'Title' cannot be selected. The flow will run a second time and succeed with the full flow. I want to add a condition so if the Title is null, the flow cancels but I used the Compose specifically because when I tried to use a Condition previously, it created a For Each that updated every single item in the SharePoint list
  • Environment #2 = Flow Part 2C
    • When SharePoint list is modified, check if has Cancelled Value
    • If yes, update the correct row in the Approvals entity to Cancel the Pending Approval
    • ISSUE #2: this process works to cancel the pending approval for the manager in Teams however the Flow Part 2A which triggered the approval doesn't get the message that it has been cancelled. The Flow eventually times out and tracks as a Failed Run
If anyone can help me with the 2 issues I would really appreciate it!
 
PART 1B
PART 2A
Categories:
I have the same question (0)
  • Suggested answer
    abm abm Profile Picture
    32,981 Most Valuable Professional on at
    Hi
     
    This could be because there are no data returned from the Get Items step. Try the below expression.
     
    if(length(body('Get_items')?['value']), first(body('Get_items')?['value'])?['Title'], 'No Data')
     
  • kagostinho Profile Picture
    42 on at
    Hi @abm abm - unfortunately that didn't work:
    Action 'Compose' failed: Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language function 'if' expects its first parameter to be of type boolean. The provided value is of type 'Integer'. Please see https://aka.ms/logicexpressions#if for usage details.'.
  • kagostinho Profile Picture
    42 on at
    I think I figured out how to tweak the formula to get ISSUE #1 - 1B formula to work:
     
    if(greater(length(body('Get_items')?['value']), 0), first(body('Get_items')?['value'])?['Title'], 'Null')
     
    Still trying to figure out ISSUE #2
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 112 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 52

#3
Ellis Karim Profile Picture

Ellis Karim 51 Super User 2026 Season 1

Last 30 days Overall leaderboard