skip to Main Content

In DataFactory, I’m creating a ForEach activity and in Items I’m using this expression:

enter image description here

    @createArray(json('{
    "daily": {
        "raw": [
            {
                "entity_name": "ent1",
                "fetchXML_file": "raw/ent1.xml",
                "destination_path_base": "/master/raw/ent1"
            },
            {
                "entity_name": "ent2",
                "fetchXML_file": "raw/ent2.xml",
                "destination_path_base": "/master/raw/ent2"
            },
            {
                "entity_name": "ent3",
                "fetchXML_file": "raw/ent3.xml",
                "destination_path_base": "/master/raw/ent3"
            }
        ]
    }
}
'))

and I want to use fetchXML_file values but it doesn’t work.

If I put this: @item().daily.raw[0].fetchXML_file it will work just for ent1, but I want to use all the values (ent1, ent2 and ent3)

I wanted to achieve this method, because it is "cleaner" than creating parameters and then modifying the json or adding more things to the json.

Can anyone help to achieve this ?

Thanks a lot!

2

Answers


  1. You are indexing to 0 at raw array so it only takes the first element. If you remove the index it should work.

    Login or Signup to reply.
  2. To pass items to For Each activity It should be in array format. your create Array and Json function converting object to array and it not iterating over the raw– array.

    To achieve this follow below steps:

    1. First take foreach activity with items as your expression.
      enter image description here
    • Under for each loop take a Set variable activity and create an Array type variable to store the raw array with value @item().daily.raw
      enter image description here
      Output of it:
      enter image description here
    1. Then take another for each activity to iterate over this array now. in items pass @variables('demo')
      enter image description here
    • Now under this foreach you will be able to iterate over the raw array and extract value oof each
      fetchXML_file
      enter image description here

    Output:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search