cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
klarson
Advocate I
Advocate I

Trigger expession invalid

Hi, I'm looking for help.

 

I am trying to create a flow and can't figure out why my trigger expression is invalid.

 

I have 2 custom lists. The one is an invoice list, where incoming invoices get added to the sharepoint list as they arrive.  Here are the column headers for that list: 

klarson_0-1694107336461.png

 

The second list is a Master PO list, where I want to track the remaining value of my Purchase Orders. Here are the column headers on that list:  

klarson_1-1694107457873.png

 

The flow I'm trying to write will sum up the value of all invoices for a specific Purchase Order on the Invoice List and put that amount in the Sum of Approved Invoices on the PO List. I'll paste screen shots of the flow I've put together, and would appreciate any help I can get in getting it up and running!

Regards,

Kirstin

 

klarson_2-1694107662351.png

 

klarson_3-1694107724554.png

 

klarson_5-1694107825069.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Ok I made an example flow and SharePoint lists. But I ask that you go look at this post about SharePoint Column InternalName and use that information to name your columns. This will help greatly with using references and expressions.

I think you should delete your list columns and recreate them to look more like my example. You can always change the display name after creating.

 

I made an example Purchase Order SharePoint list that has 2 purchase Orders:

Purchase Order Initial List ViewPurchase Order Initial List View

Here are the column types of the Purchase Order List:

Purchase Order List SettingsPurchase Order List Settings

 

Then I made an Invoice List with 3 Example Invoices:

Invoice Tracker with 3 submitted InvoicesInvoice Tracker with 3 submitted Invoices

Here are the column types of the Invoice SharePoint list:

Invoice List SettingsInvoice List Settings

 

The Invoice List has a Choice type column "InvoiceReviewStatus" that will be used to identify that status of a created invoice/item.

Invoice Review Status Choice ColumnInvoice Review Status Choice Column

 

So then when an Invoice is Reviewed, it can have the status changed to "Approved" in the choice column. See below I changed the status of the first invoice.1st Invoice Approved1st Invoice Approved

 

Any creation of an item or modification will trigger the flow, but it uses a Condition to check the column value of "InvoiceReviewStatus" to determine if the flow should continue or stop running.

Flow Overview All StepsFlow Overview All Steps

In the condition it is checking the InvoiceReviewStatus Value which is different than the InvoiceReviewStatus. Choice columns will have multiple dynamic content options. One of them is the Value which will just be the word, the other will be a different output showing the whole choice box that we don't want.

SharePoint Choice Column VALUESharePoint Choice Column VALUE

 

The second part of the flow is where there is a Get Items action that is getting all of the rows from the PurchaseOrders SharePoint list. Directly in the Get Items there is a Filter Query field that is being used to only get items with match Purchase Order Numbers.

 

The Filter Query is in the format of PurchaseOrderNumber equals the InvoicePurchaseOrderNumber.

Since the purchase order number are literally in a number value, the Filter Query format is:

ColumnName eq NumberValue

If the purchase order number was a text/string or trying to filter by another column the Filter Query format is:

ColumnName eq 'TextValue' 

If it is a text it needs ' single quotes around the value.

 

Flow Overview - Zoom Get Items and Update ItemsFlow Overview - Zoom Get Items and Update Items

 

 The Update Item step will add the amount of the new invoice to the Sum of Approved Invoices. This is basically taking the value from Get Items and adding it to the trigger Invoice Amount. 

 

add(items('Apply_to_each')?['SumofApprovedInvoices'],triggerOutputs()?['body/InvoiceAmount'])

 

 

The expression is put in the Expression fx box to be added into the field:

Add ExpressionAdd Expression

 

The remaining purchase order amount uses the previous add expression, but it also includes a subtract expression. The is getting the PurchaseOrderTotalCost and subtracting the SumofApprovedInvoices to get the remaining.

 

sub(items('Apply_to_each')?['PurchaseOrderTotalCost'],add(items('Apply_to_each')?['SumofApprovedInvoices'],triggerOutputs()?['body/InvoiceAmount']))

 

 

Here is the expression in the fx field:

Subtract ExpressionSubtract Expression

 

Here is the reference for how the expression (formulas) are created:

add() expression to sum values

subtract sub() expression  to subtract values

 

So here is the example of changing an invoice to submitted and then the result of the Purchase Order list:

Invoice List with First Invoice ApprovedInvoice List with First Invoice ApprovedPurchase Order List After First Invoice was ApprovedPurchase Order List After First Invoice was Approved

You can see the $1,550 InvoiceAmount was added to the Purchase Order List in the SumofApprovedInvoices and it was also subtracted from the RemainingPurchaseOrder column.

 

Here is the example after the remaining 2 invoices were changed to Approved:

Invoice List Remaining Invoices ApprovedInvoice List Remaining Invoices ApprovedPurchase Order List after All Invoices ApprovedPurchase Order List after All Invoices Approved

 

This is a very basic example. You can add features and functions to this all day, but I recommend getting the basic flow working and then building things on top of that.

 

Give this a try and let me know if it works for you. Please create new column names because it will make all of this much easier. See this post for why column names help.

View solution in original post

12 REPLIES 12

Why do you need to sum up ALL of the invoices values up update a single Purchase Order each time an Invoice is created or modified?

 

Wouldn't it be easier to have a flow that triggers when an Invoice status is changed to Approved that will add to the Purchase Order approved sum? So it is individually adding to the Purchase Order approved sum as the invoice is changed to approved.

Sure, I could possibly do that. I'd have to figure out how to write that flow--I'm new at this. But will that solve the invalid trigger expression problem? 

For the specific "trigger expression problem" I would need more information. Like being able to see the full expression you are using as well as what exactly the error message states.

 

For a separate flow that triggers only on Approved invoices, you need to tell me more about how an Invoice becomes Approved. Because your current example, if it worked, you expect the Purchase Order sum to be updated anytime an Invoice is created or modified. So I don't understand how you were differentiating an Approved invoice if the flow was going to trigger on all invoices.

klarson
Advocate I
Advocate I

I can provide that information.

Originally, I was using a condition "invoice approved for payment? is equal to yes", but it also resulted in an error message. So I changed it to invoice amount has a value just temporarily. But you are right--my intention is that once someone has reviewed the invoice and updates that field, a yes response would trigger the flow.

 

Here is the full expression I used to create the filter array: 

@equals(trigger(Outputs()?['body/Purchase Order/String'], item()?['Purchase Order/String'])

 

I think that is saying create a list of all the Purchase Orders in the nvoicing list that have a matching Purchase Order in the Purchase Order list.  I have tried replacing the word  "string" with "value," but it doesn't help. Both lists, for the Purchase Order columns, are defined as text.

 

Here is the error message I get:

klarson_0-1694118119567.png

I think that addresses all of your comments. Thanks for trying to help me!

 

 

 

Ok I made an example flow and SharePoint lists. But I ask that you go look at this post about SharePoint Column InternalName and use that information to name your columns. This will help greatly with using references and expressions.

I think you should delete your list columns and recreate them to look more like my example. You can always change the display name after creating.

 

I made an example Purchase Order SharePoint list that has 2 purchase Orders:

Purchase Order Initial List ViewPurchase Order Initial List View

Here are the column types of the Purchase Order List:

Purchase Order List SettingsPurchase Order List Settings

 

Then I made an Invoice List with 3 Example Invoices:

Invoice Tracker with 3 submitted InvoicesInvoice Tracker with 3 submitted Invoices

Here are the column types of the Invoice SharePoint list:

Invoice List SettingsInvoice List Settings

 

The Invoice List has a Choice type column "InvoiceReviewStatus" that will be used to identify that status of a created invoice/item.

Invoice Review Status Choice ColumnInvoice Review Status Choice Column

 

So then when an Invoice is Reviewed, it can have the status changed to "Approved" in the choice column. See below I changed the status of the first invoice.1st Invoice Approved1st Invoice Approved

 

Any creation of an item or modification will trigger the flow, but it uses a Condition to check the column value of "InvoiceReviewStatus" to determine if the flow should continue or stop running.

Flow Overview All StepsFlow Overview All Steps

In the condition it is checking the InvoiceReviewStatus Value which is different than the InvoiceReviewStatus. Choice columns will have multiple dynamic content options. One of them is the Value which will just be the word, the other will be a different output showing the whole choice box that we don't want.

SharePoint Choice Column VALUESharePoint Choice Column VALUE

 

The second part of the flow is where there is a Get Items action that is getting all of the rows from the PurchaseOrders SharePoint list. Directly in the Get Items there is a Filter Query field that is being used to only get items with match Purchase Order Numbers.

 

The Filter Query is in the format of PurchaseOrderNumber equals the InvoicePurchaseOrderNumber.

Since the purchase order number are literally in a number value, the Filter Query format is:

ColumnName eq NumberValue

If the purchase order number was a text/string or trying to filter by another column the Filter Query format is:

ColumnName eq 'TextValue' 

If it is a text it needs ' single quotes around the value.

 

Flow Overview - Zoom Get Items and Update ItemsFlow Overview - Zoom Get Items and Update Items

 

 The Update Item step will add the amount of the new invoice to the Sum of Approved Invoices. This is basically taking the value from Get Items and adding it to the trigger Invoice Amount. 

 

add(items('Apply_to_each')?['SumofApprovedInvoices'],triggerOutputs()?['body/InvoiceAmount'])

 

 

The expression is put in the Expression fx box to be added into the field:

Add ExpressionAdd Expression

 

The remaining purchase order amount uses the previous add expression, but it also includes a subtract expression. The is getting the PurchaseOrderTotalCost and subtracting the SumofApprovedInvoices to get the remaining.

 

sub(items('Apply_to_each')?['PurchaseOrderTotalCost'],add(items('Apply_to_each')?['SumofApprovedInvoices'],triggerOutputs()?['body/InvoiceAmount']))

 

 

Here is the expression in the fx field:

Subtract ExpressionSubtract Expression

 

Here is the reference for how the expression (formulas) are created:

add() expression to sum values

subtract sub() expression  to subtract values

 

So here is the example of changing an invoice to submitted and then the result of the Purchase Order list:

Invoice List with First Invoice ApprovedInvoice List with First Invoice ApprovedPurchase Order List After First Invoice was ApprovedPurchase Order List After First Invoice was Approved

You can see the $1,550 InvoiceAmount was added to the Purchase Order List in the SumofApprovedInvoices and it was also subtracted from the RemainingPurchaseOrder column.

 

Here is the example after the remaining 2 invoices were changed to Approved:

Invoice List Remaining Invoices ApprovedInvoice List Remaining Invoices ApprovedPurchase Order List after All Invoices ApprovedPurchase Order List after All Invoices Approved

 

This is a very basic example. You can add features and functions to this all day, but I recommend getting the basic flow working and then building things on top of that.

 

Give this a try and let me know if it works for you. Please create new column names because it will make all of this much easier. See this post for why column names help.

klarson
Advocate I
Advocate I

I have re-written the order of this flow, and think I'm a lot closer to getting it to work, but just need help now on the last step.

 

So, the new flow says when the Invoice list is modified and the Invoice Submitted value = yes, create a filter array for the Purchase Order value and compose it as the first array then update the PO List by matching the output of the array (which should be the purchase order number) and update the Sum of Approved Invoices field with the newly approved invoice amount.  I think what I'm missing is that amount, but I'm stuck on how to get it into this flow.  Here is a screenshot. The last function in the Sum of Approved Invoices reads "add(triggerOutputs()?['body/Amount'], outputs('Compose')?["Sum of Approved Invoices'])

 

klarson_1-1694125990959.png

 

 

The example I provided is what you should use. It is the least amount of steps to accomplish what you want.

klarson
Advocate I
Advocate I

  • Thank you, I will work on you instructions today!
klarson
Advocate I
Advocate I

Thank you so much for your very helpful reply. I really appreciate that you took the time to provide me with lots of learning resources, and explained each step.  It took me a little time to re-create the two lists, but once I did that, I followed your instructions and created the flow.  It ran successfully, but resulted in one glitch. In the PO Tracker Sum Invoiced field, it recorded double the amount that I approved in the invoice list.  Any idea why?  

 

Again, thank you so much for the excellent instruction. I'm so appreciative for your clear, easy to follow tutorial!

Here are some screenshots of the results:

klarson_0-1694196574184.png

klarson_1-1694196630296.png

klarson_2-1694196737284.png

klarson_3-1694196805631.png

klarson_4-1694196842486.png

klarson_5-1694196890623.png

klarson_6-1694196942138.png

 

 

 

 

 

This works perfectly.  Ignore my question about the doubling of the total invoiced amount--the flow ran twice. I've added several additional test invoices, and it is performing exactly as I was hoping. You are amazing!!!

Glad you got it working 👍

 

You can go change the column display name and it won't be a run together words, but the Internal Name of the column will always stay the same.

For example if rename your column "ApprovalDate" to "Date Invoice Approved", the InternalName will always be "ApprovalDate" to use in your flow, but what is displayed on the list will be "Date Invoice Approved".

 

One more thing:

Can go up to my previous reply that has all of the instructions and screenshots and mark that Accept as Solution so this will be resolved?  It will make it easier for others to find the solution, and I get those sweet fake internet points!

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (928)