access a foreach value in response section logic app - azure

while accessing the data iterated over foreach is not visible outside of foreach loop, Even if i can access then again foreach is loaded automatically.
can somone explain about this typical behavior of foreach in logic app
?
SS for your reference :
Timely help would much appreciated...
Thanks in advance !!!

The output of an action called within a ForEach would be an array of objects. You can use the square bracket operator in case you want one specific item or any of the collection functions as described here:
https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language#functions

Related

Azure DataFactory Params - Newbie Question

I'm working with ADF and trying to leverage parameters to make life easier and reduce the number of objects being created in the ADF itself. What I am trying to do, would appear on the surface to be extremely simple, bu in reality its driving me slowly crazy. Would greatly appreciate any assistance!
I am trying to set up a parameterised dataset to be used as a sink target. Inside that dataset I have added a param named "filenames" of type string. In the connection tab I have added that param to the file part of the path. The folder part point to my Azure Data Lake folder and the file part is set to: #dataset().filename which is the result of choosing 'dynamic content' then selecting the param.
So far so good.. my sink target is, as far as I am aware, ready to receive "filenames" to write out to.
This is where it all goes wrong.
I now create a new pipeline. I want to use a list or array of values inside that pipeline which represent the names of the files I want to process. I have been told that I'll need a Foreach to send each of the values one at a time to the COPY DATA task behind the Foreach. I am no stranger to Foreach type loops and behaviors.. but for the life of me I CANNOT see where to set up the list of filenames. I can create a param as a type "array" but how the heck do you populate it?
I have another use case which this problem is preventing me from completing. This use case is, I think, the same problem but perhaps serves to explain the situation more clearly. It goes like this:
I have a linked service to a remote database. I need to copy data from that database (around 12 tables) into the data lake. At the moment I have about 12 "COPY DATA" actions linked together - which is ridiculous. I want to use a Foreach loop to copy the data from source to data lake one after the other. Again, I can set up the sink dataset to be parameterised, just fine... but how the heck do I create the array/list of table names in the pipeline to pass to the sink dataset?
I add the Foreach and inside the foreach a "COPY DATA" but where do I add all the table names?
Would be very grateful for any assistance. THANK YOU.
If you want to manually populate values of an array as a pipeline parameter, you create the parameter with Array type and set the value with syntax like: ["File1","File2","File3"]
You then iterate that array using a ForEach activity.
Inside the ForEach, you reference #item() to get the current file name value the loop is on.
You can also use a Lookup activity to get data from elsewhere and iterate over that using the ForEach.

Azure Logic App - Foreach over sql resultset

I'm using an Execute Sql Query action in logic app.
Returned result is composed of 1..n tables ("selects").
I want to create a csv table and send it over tfs.
The issue I'm having is that the tables are elements of resultset, and not part of an array.
Is there some way to perform ForEach action on the resultset elements (i.e. - 'Table1', 'Table2', etc...)?
Is there some way to perform ForEach action on the resultset elements (i.e. - 'Table1', 'Table2', etc...)?'
According to the mentioned data format, it seems that it is not supported via foreach action in logic app.
If Azure function is acceptable, I recommend that you could use the Azure function to implement it with your customized logic to deal with data.
Foreach on a Resultset will return JSON object of each row.
I couldn't find any option DesignView to extract the value but you can achieve same in CodeView by assigning following code to your variable in CodeView.
In below MEETINGID is my column name.
"#{items('For_each')?['MEETINGID']}"
"imeetingid": "#{items('For_each')?['MEETINGID']}"
In DesignView, you can use Parse JSON after SQL querying step.
Then, you can use for each in order to reach each database record. Because SQL resultset returns as JSON object in the Logic App.

Nested forEach activity in Azure Data factory V2

I am trying to use two forEach activities to iterate on subfolders of folders with parameters to get metadata of subfolders. I have forEach1 and forEach2 with their own items array. Within the second for loop I need to combine both for loops' item() in a Metada activity to access my dataset like #item1()#item2(). Is this possible?
Nested foreach activity is not allowed. But you could use an execute pipeline activity inside the foreach activity. And in the nested pipeline, you could have another foreach.
It is possible but the second ForEach activity needs to be inside the first one, not another activity in the pipeline.
As you have it now, the first ForEach will run until completion, then the second one will start and you cannot access the items in the first one.
Hope this helped!

Data returned if GetItems if query did not match

This is really a simple question. What does GetItems method return if SPQueryobject did not find any match? if i call the update method, if it did find anything. Will it add it?
I'm at the point of investigating a bug and I still don't have a environment for me to test and I'm new to SharePoint development so guys, please be gentle :D
The item will be added anyway. It doesn't matter if there are any items in the SPListItemCollection.
SPList.AddItem() uses this behavior to avoid loading all of the items in the list. One could write:
SPList list = ...
list.Items.Add();
This loads all the items in the list, which might be slow for large item sets.
SPList.AddItem() retrieves the SPListItemCollection by executing a CAML query that returns no items (ID == -1) and calls then the Add method.

Clean document roles in a Doc Library

I have been developing an event handler to clean up the RolesAssignments of the new item of a document library in MOSS. I’ve searched for a method that could clean all the RolesAssignments efficiently, although the best way I found seams to be loop through the RolesAssignments and delete one by one? Is there another way to clean all the RolesAssignments for an item?
The code I’m using for cleaning the RolesAssignments look like this:
for (int i = ListItem.RoleAssignments.Count - 1; i >= 0; --i)
{
ListItem.RoleAssignments.Remove(i);
}
Does anyone have any ideas on how to deal with this?
The example you've given within the body of your question is the most correct way to do this. ResetRoleInheritance and BreakRoleInheritance may do what you need, but this is the side-effect of the operations they perform. Their purpose is not to remove RoleAssignments, but rather operate on role inheritance. From MSDN:
ResetRoleInheritance - "Removes the local role assignments and reverts to role assignments from the parent object."
BreakRoleInheritance - "Creates unique role assignments for the item rather than inheriting them from a parent."
If role inheritance is already broken and you are using specific role assignments, you should remove them using a loop as you have in your question.
I have the answer, put the propertie SPListItem.BreakRoleInheritance(false) to break the role inheritance and remove the role assignments.
How about ResetRoleInheritance? This should clear out all of the RoleAssignments.

Resources