cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Error using FORMAT in CREAT CSV TABLE

I am trying to format a few number fields (only starting with one so far) from JSON data brought in. I PARSE JSON to get the fields to use in the subsequent actions. I then use the FORMAT NUMBER action to get the number into Currency format. I then want to use that formatted field in my output when issuing the CREATE CSV TABLE action. But I get the error below. I am lost on how to do this. Any help would be great. Thanks!

 

Error:

(x) Flow save failed with code 'invalidTemplate' and message The template validation failed: 'The inputs of template action 'Create_CSV_table' at lire 1 and column '3984' is Invalid. Action 'Apply_to_each' must be a parent 'foreach' scope of actior 'Create_CSV_table' to be referenced by 'repeatltems' cr 'items' functions.'.'.

 

My flow:

dBrand_0-1619554617278.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for posting the JSON here @dBrand !

I got the Flow working with your JSON and JSON Schema with minor changes.

  1. At the beginning of the Flow please initialize a String Variable
  2. In Apply to Each, after Formatted Number, add Set a Variable action and configure it as follows
    1. NiloferA_0-1620101912949.png
    2. In double quotes, select the output from Formatted Number
  3. In Compose Total Pay action, add this expression - replace(string(item()),string(item()?['PayTotalSum']), variables('MyString'))
    1. NiloferA_1-1620102128149.png
  4. Keep the Append to Array Variable as is from the previous replies, the expression should be - json(outputs('Compose_Total_Pay'))
  5. At the end, after the Apply to Each, you already have Create CSV Table action in your Flow, pass the Array in the Input here.

And that's it. I am certain this should work for you now! Fingers crossed! 😛

Please give a Kudo or Mark my respective Replies as Solution once this works for you.

View solution in original post

17 REPLIES 17

Reallyhoping someone has some ideas on this. Still stuck. Thanks!

Hello @dBrand !

 

I notice that you have added your action of Create CSV Table outside of the Apply to Each action and still trying to refer the "Current item" which is coming from Apply to Each.

Try moving Create CSV Table action within Apply to Each after the Format action and it should work for you.

 

Hope this helps! Please give a Kudo and mark this Reply as solution if you found it helpful.

I tried this, but now get the error:

BadRequest. The 'from' property value in the 'table' action inputs is of type 'Object'. The value must be of type 'Array'.

 

Here is the flow:

dBrand_0-1619888538505.png

 

Additionally, I am trying to get the columns in the CSV to be from the original parsed Json as well as some fields from the Format steps (since they will provide a formatted dollar amount, where the Parsed data does not).

 

Still stuck on this for days, and can't really find an answer to this, and my deadline is Monday.

Hello @dBrand ,

I got your problem statement working. Please make below changes to your flow to achieve the requirement,

  1. Initialize an Array (MyArray) Variable
  2. Then in Apply to Each action, after Format Number, add a Compose action and add the expression in input as follows
    1. replace(string(item()), item()['ro'] (name of the field you are trying to replace with formatted number)(Output from Format Number Dynamic Content))
  3. Then add Append to Array Variable action and add the following expression in Value
    1. json(outputs('Compose'))
      NiloferA_0-1619975928309.png
  4. Outside of the Apply to Each action, add the Create CSV Table action and pass the Array to it.

NiloferA_1-1619975973709.png

This should solve your issues. Now the problem with your Flow is that

  1. You are traversing JSON Body and passing each item (which is of type Object) to Create a CSV Table action, this action accepts an Array not an Object
  2. You are formatting some field from the JSON but you are never updating the current item thus your updated format will not appear in the final result.

Hope this helps you out and you should be good for your deadline! If you still face any issues, feel free to post a reply and I will be happy to help!

Please give a Kudo and mark this Reply as solution if you found it helpful.

 

Thanks, sorry, but I'm stuck. In step 2a - 

  1. replace(string(item()), item()['ro'] (name of the field you are trying to replace with formatted number) (Output from Format Number Dynamic Content))

I replace it with my data, below, but I am getting an invalid expression. Not sure of the syntax.

replace(string(item()), item()['PayTotalSum'], (outputs('Format_number_Total_Pay')?['body']))

 

But, I do understand the concept of the solution you provided, which seems to be the answer, if I could just get past the syntax issue I am having.

 

Thanks!

No problem @dBrand , so your expression should look like this

replace(string(item()),item()?['PayTotalSum'], outputs('Format_number_Total_Pay')?['body'])
Get rid of the brackets near Format Number Output.

Just about there. Now getting past that and getting error creating the CSV table, which I am doing from the array (or so I believe):

dBrand_0-1620001680829.png

 

Hello @dBrand ,

It looks like you are passing string and not array to the CSV table action. Can you please confirm the type of the variable you have initialized?

NiloferA_1-1620012507787.png

NiloferA_6-1620012808188.png

 

NiloferA_2-1620012600262.png

NiloferA_3-1620012623689.png

NiloferA_5-1620012725427.png

 

Also, if possible please post screenshots of your flow here for me to assess the problem better! 🙂

From what I see, I am passing an Array, which is why I am confused. But below are screenshots to help better see my flow, as requested. Thanks!!!

 

dBrand_0-1620048682727.png

 

 

The Apply to each breakout:

dBrand_1-1620048714310.png

 

Ok, I got your issue.

In Append to array variable, Please add the value as an expression and not as text in the field.

NiloferA_0-1620051628788.png

 

Sorry, I now feel like a nuisance, but now getting error:

 

Unable to process template language expressions in action 'Append_to_array_variable' inputs at line '1' and column '2894': 'The template language function 'json' expects its parameter to be a string or an XML. The provided value is of type 'Array'. Please see https://aka.ms/logicexpressions#json for usage details.'.

 

To be certain, you wanted it to be 'Compose' and not 'Compose Total Pay'? Either way didn't work though. But the other way gave a different error.

Dont worry about it, it's fine.

Although, I just noticed that in the screenshot you provided above, the expression in Append to Array Variable action is - json(outputs(Output)) which is incorrect. 

Please remove the value, then when the Dynamic Content popup comes up, click on Expression and then type in json() and within this function add the Output of Compose Total Pay from Dynamic Content.

So the expressions should look like this -->   json(outputs('Compose_Total_Pay')) 

Please refer the Screenshots below

NiloferA_0-1620069238746.png

NiloferA_1-1620069292474.png

NiloferA_2-1620069333281.png

 

 

I had also tried that, thinking that's what you meant. But it gives a different error:

 

InvalidTemplate. Unable to process template language expressions in action 'Append_to_array_variable' inputs at line '1' and column '2894': 'The template language function 'json' parameter is not valid. The provided value '{"CleaningHrsSum":2,"CleaningRate":125,"ContainerSum":5,"HolidayHoursSum":0,"HolidayPay":0,"HolidayRate":0,"HoursSum":0,"Non_PowderRate":100,"OTHoursSum":0,"OTPay":0,"OTRate":0,"PayTotalSum":$875.00,"PowderContainerSum":1,"PowderRate":125,"RegPay":0,"RegRate":0,"Worker":19,"WorkerGrpBy":[{"AddlHours":0,"Cleaning_Hours":2,"Containers":5,"HolidayHours":0,"Hours":8,"PayAmount":$875.00,"Pkey":292,"PowderContainers":1,"RateCleaning":125,"RateHoliday":0,"RateNonPowder":100,"RateOT":0,"RatePowder":125,"RateReg":0,"RecType":"L","Related_Pkey":281,"Status":"S","Submitted":true,"cDate":20210402}],"WorkerName":"Pam , Raff"}' cannot be parsed: 'Unexpected character encountered while parsing value: $. Path 'PayTotalSum', line 1, position 191.'. Please see https://aka.ms/logicexpressions#json for usage details.'.

 

 

Not sure if this is due to my Schema and maybe the way we write this needs to be diffferent because of that?

 

Schema:

{
  "type""array",
  "items": {
    "type""object",
    "properties": {
      "CleaningHrsSum": {
        "type""number"
      },
      "CleaningRate": {
        "type""number"
      },
      "ContainerSum": {
        "type""number"
      },
      "HolidayHoursSum": {
        "type""number"
      },
      "HolidayPay": {
        "type""number"
      },
      "HolidayRate": {
        "type""number"
      },
      "HoursSum": {
        "type""number"
      },
      "Non_PowderRate": {
        "type""number"
      },
      "OTHoursSum": {
        "type""number"
      },
      "OTPay": {
        "type""number"
      },
      "OTRate": {
        "type""number"
      },
      "PayTotalSum": {
        "type""number"
      },
      "PowderContainerSum": {
        "type""number"
      },
      "PowderRate": {
        "type""number"
      },
      "RegPay": {
        "type""number"
      },
      "RegRate": {
        "type""number"
      },
      "Worker": {
        "type""integer"
      },
      "WorkerGrpBy": {
        "type""array",
        "items": {
          "type""object",
          "properties": {
            "AddlHours": {
              "type""number"
            },
            "Cleaning_Hours": {
              "type""number"
            },
            "Containers": {
              "type""number"
            },
            "HolidayHours": {
              "type""number"
            },
            "Hours": {
              "type""number"
            },
            "PayAmount": {
              "type""number"
            },
            "Pkey": {
              "type""integer"
            },
            "PowderContainers": {
              "type""number"
            },
            "RateCleaning": {
              "type""number"
            },
            "RateHoliday": {
              "type""number"
            },
            "RateNonPowder": {
              "type""number"
            },
            "RateOT": {
              "type""number"
            },
            "RatePowder": {
              "type""number"
            },
            "RateReg": {
              "type""number"
            },
            "RecType": {
              "type""string"
            },
            "Submitted": {
              "type""boolean"
            },
            "cDate": {
              "type""integer"
            }
          },
          "required": [
            "AddlHours",
            "Cleaning_Hours",
            "Containers",
            "HolidayHours",
            "Hours",
            "PayAmount",
            "Pkey",
            "PowderContainers",
            "RateCleaning",
            "RateHoliday",
            "RateNonPowder",
            "RateOT",
            "RatePowder",
            "RateReg",
            "RecType",
            "Submitted",
            "cDate"
          ]
        }
      },
      "WorkerName": {
        "type""string"
      }
    },
    "required": [
      "CleaningHrsSum",
      "ContainerSum",
      "HolidayHoursSum",
      "HolidayPay",
      "HoursSum",
      "OTHoursSum",
      "OTPay",
      "PayTotalSum",
      "PowderContainerSum",
      "RegPay",
      "Worker",
      "WorkerName"
    ]
  }
}

I agree that might be the reason, can you paste the actual JSON here please?

I will add it in my flow and troubleshoot.

[
{
"CleaningHrsSum": 2,
"CleaningRate": 125,
"ContainerSum": 5,
"HolidayHoursSum": 0,
"HolidayPay": 0,
"HolidayRate": 0,
"HoursSum": 0,
"Non_PowderRate": 100,
"OTHoursSum": 0,
"OTPay": 0,
"OTRate": 0,
"PayTotalSum": 875,
"PowderContainerSum": 1,
"PowderRate": 125,
"RegPay": 0,
"RegRate": 0,
"Worker": 19,
"WorkerGrpBy": [
{
"AddlHours": 0,
"Cleaning_Hours": 2,
"Containers": 5,
"HolidayHours": 0,
"Hours": 8,
"PayAmount": 875,
"Pkey": 292,
"PowderContainers": 1,
"RateCleaning": 125,
"RateHoliday": 0,
"RateNonPowder": 100,
"RateOT": 0,
"RatePowder": 125,
"RateReg": 0,
"RecType": "L",
"Related_Pkey": 281,
"Status": "S",
"Submitted": true,
"cDate": 20210402
}
],
"WorkerName": "Pat , Barney"
},
{
"CleaningHrsSum": 0,
"CleaningRate": 125,
"ContainerSum": 5,
"HolidayHoursSum": 0,
"HolidayPay": 0,
"HolidayRate": 0,
"HoursSum": 0,
"Non_PowderRate": 100,
"OTHoursSum": 0,
"OTPay": 0,
"OTRate": 0,
"PayTotalSum": 625,
"PowderContainerSum": 1,
"PowderRate": 125,
"RegPay": 0,
"RegRate": 0,
"Worker": 23,
"WorkerGrpBy": [
{
"AddlHours": 0,
"Cleaning_Hours": 0,
"Containers": 5,
"HolidayHours": 0,
"Hours": 8,
"PayAmount": 625,
"Pkey": 293,
"PowderContainers": 1,
"RateCleaning": 125,
"RateHoliday": 0,
"RateNonPowder": 100,
"RateOT": 0,
"RatePowder": 125,
"RateReg": 0,
"RecType": "L",
"Related_Pkey": 281,
"Status": "S",
"Submitted": true,
"cDate": 20210402
}
],
"WorkerName": "Dey, Sam"
},
{
"CleaningHrsSum": 0,
"CleaningRate": 0,
"ContainerSum": 0,
"HolidayHoursSum": 8,
"HolidayPay": 200,
"HolidayRate": 25,
"HoursSum": 0,
"Non_PowderRate": 0,
"OTHoursSum": 0,
"OTPay": 0,
"OTRate": 24.75,
"PayTotalSum": 200,
"PowderContainerSum": 0,
"PowderRate": 0,
"RegPay": 0,
"RegRate": 16.5,
"Worker": 15,
"WorkerGrpBy": [
{
"AddlHours": 0,
"Cleaning_Hours": 0,
"Containers": 0,
"HolidayHours": 8,
"Hours": 0,
"PayAmount": 200,
"Pkey": 307,
"PowderContainers": 0,
"RateCleaning": 0,
"RateHoliday": 25,
"RateNonPowder": 0,
"RateOT": 24.75,
"RatePowder": 0,
"RateReg": 16.5,
"RecType": "M",
"Related_Pkey": 284,
"Status": "S",
"Submitted": true,
"cDate": 20210402
}
],
"WorkerName": "Etlan , Cam"
},
{
"CleaningHrsSum": 0,
"CleaningRate": 0,
"ContainerSum": 0,
"HolidayHoursSum": 0,
"HolidayPay": 0,
"HolidayRate": 0,
"HoursSum": 8,
"Non_PowderRate": 0,
"OTHoursSum": 0,
"OTPay": 0,
"OTRate": 33,
"PayTotalSum": 176,
"PowderContainerSum": 0,
"PowderRate": 0,
"RegPay": 176,
"RegRate": 22,
"Worker": 36,
"WorkerGrpBy": [
{
"AddlHours": 0,
"Cleaning_Hours": 0,
"Containers": 0,
"HolidayHours": 0,
"Hours": 8,
"PayAmount": 176,
"Pkey": 315,
"PowderContainers": 0,
"RateCleaning": 0,
"RateHoliday": 0,
"RateNonPowder": 0,
"RateOT": 33,
"RatePowder": 0,
"RateReg": 22,
"RecType": "D",
"Related_Pkey": 314,
"Status": "S",
"Submitted": true,
"cDate": 20210402
}
],
"WorkerName": "Ady, John"
},
{
"CleaningHrsSum": 2,
"ContainerSum": 10,
"HolidayHoursSum": 8,
"HolidayPay": 200,
"HoursSum": 8,
"OTHoursSum": 0,
"OTPay": 0,
"PayTotalSum": 1876,
"PowderContainerSum": 2,
"RegPay": 176,
"Worker": 0,
"WorkerName": "TOTAL:"
}
]

Thanks for posting the JSON here @dBrand !

I got the Flow working with your JSON and JSON Schema with minor changes.

  1. At the beginning of the Flow please initialize a String Variable
  2. In Apply to Each, after Formatted Number, add Set a Variable action and configure it as follows
    1. NiloferA_0-1620101912949.png
    2. In double quotes, select the output from Formatted Number
  3. In Compose Total Pay action, add this expression - replace(string(item()),string(item()?['PayTotalSum']), variables('MyString'))
    1. NiloferA_1-1620102128149.png
  4. Keep the Append to Array Variable as is from the previous replies, the expression should be - json(outputs('Compose_Total_Pay'))
  5. At the end, after the Apply to Each, you already have Create CSV Table action in your Flow, pass the Array in the Input here.

And that's it. I am certain this should work for you now! Fingers crossed! 😛

Please give a Kudo or Mark my respective Replies as Solution once this works for you.

@NiloferA This worked!!! Thanks for sticking in there. Should be easier to do than they make it, but I guess MS will improve it as time goes on. Now I need to format more fields (like a dozen of them). This will be a pain. Hope that goes better, now that I have the rest working. THANKS AGAIN!

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!

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.    

Summer of Solutions | Week 3 Results | Win free tickets to the Power Platform Conference

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  

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 (5,524)