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

Community site session details

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

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,852 Most Valuable Professional on at
    Cancel Pending Teams Approval Flow
    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
    Cancel Pending Teams Approval Flow
    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
    Cancel Pending Teams Approval Flow
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard