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:
@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!
Thanks for posting the JSON here @dBrand !
I got the Flow working with your JSON and JSON Schema with minor changes.
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.
[
{
"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:"
}
]
I agree that might be the reason, can you paste the actual JSON here please?
I will add it in my flow and troubleshoot.
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:
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
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.
Ok, I got your issue.
In Append to array variable, Please add the value as an expression and not as text in the field.
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!!!
The Apply to each breakout:
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?
Also, if possible please post screenshots of your flow here for me to assess the problem better! 🙂