Hi All
I am getting data from data verse table with specific set of columns in flow and i am getting some unwanted columns.
I want to remove those unwanted columns
Below is my Json returned in compose .I would like to remove the first 4 columns from the below json array and last but one column in the below json "cr12b_campaignid@odata.type":
Solved! Go to Solution.
you can still do it with a select, but in text mode, as long as the columns you want to remove, are always the same, like this:
As you can see, it does not matter which columns are present, it outputs the whole array, removing unwantedField1 and unwantedField2.
Does that make sense?
In your case it is actually a little more complex because removeProperty function will not work with any field name with a period/fullstop in it. But this does what you want:
Expressions are:
Select From:
json(replace(string(outputs('Array')), '@odata.', 'odata'))
Select Map:
removeProperty(removeProperty(removeProperty(removeProperty(removeProperty(item(), 'cr12b_campaignid@odatatype'), 'odatatype'), 'odataid'), 'odataetag'), 'odataeditLink')
Simply pass your JSON array into a select action and reformat it to your requirements. There is another method which involves the use of the removeProperty expression, but I think the select action would be best for you. Give it a try, are you familiar with how to use it?
Thanks Paulie78,
In my case the number of columns varies so i can't use select . When i tried to use removeproperty i got below error
The template language function 'removeProperty' expects its first parameter to be of type object. The provided value is of type 'Array'.'.
I converted it into json
How does the number of columns change if it is coming from a dataverse table?
I have to filter the table based on some category and for each category the number of columns would be varying
E.g :
category 1 : 5 columns
category 2: 8 columns
I am passing column names to the flow from powerapps
you can still do it with a select, but in text mode, as long as the columns you want to remove, are always the same, like this:
As you can see, it does not matter which columns are present, it outputs the whole array, removing unwantedField1 and unwantedField2.
Does that make sense?
In your case it is actually a little more complex because removeProperty function will not work with any field name with a period/fullstop in it. But this does what you want:
Expressions are:
Select From:
json(replace(string(outputs('Array')), '@odata.', 'odata'))
Select Map:
removeProperty(removeProperty(removeProperty(removeProperty(removeProperty(item(), 'cr12b_campaignid@odatatype'), 'odatatype'), 'odataid'), 'odataetag'), 'odataeditLink')
Excellent Paulie78 got the desired result .
Only thing is my column names have "." so can't use removeproperty on it , has to rename the column names from output . some thing like this and then used removeproperty.
JSON(replace(replace(replace(replace(string(outputs('Compose_2')), '@odata.type', 'odatatype'),'@odata.id', 'odataid'),'@odata.etag','odataetag'),'@odata.editLink','odataeditLink'))
Yes, I posted the replace code above also. 😃 Well done! 😘
HI @Paulie78 Just want to check can i use the removeproperty with in apply each loop as my columns are dynamically passed .
I will get an array of columns to be removed and would liek to pass in the item of array to the removeproperty . I tried it but it is not working .
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
74 | |
27 | |
22 | |
15 | |
14 |
User | Count |
---|---|
143 | |
43 | |
42 | |
34 | |
30 |