<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: The execution of template action 'MainForEach1' failed: the result of the evaluation of 'foreach' in Pipelines</title>
    <link>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4145574#M5356</link>
    <description>&lt;P&gt;Found a resolution using parameters and introducing it directly to the copy activity. No need for more energy on this ticket.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2024 18:26:53 GMT</pubDate>
    <dc:creator>PWTRyanWhite</dc:creator>
    <dc:date>2024-09-11T18:26:53Z</dc:date>
    <item>
      <title>The execution of template action 'MainForEach1' failed: the result of the evaluation of 'foreach'</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4143367#M5329</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to setup a pipeline that will take a JSON example and pass it through a for-each loop that will be used to post to a API URL. Below is the setup I have intially created. Keep in mind, the for-each loop does work when passing none complex JSON to the loop.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;^ above is 'Set Variable2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the JSON I am using to pass to the loop&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {"lane_id": "SEA-MFR", "origin": "SEA", "destination": "MFR", "input_miles": 688},
  {"lane_id": "GSP-GSP", "origin": "SEA", "destination": "GSP", "input_miles": 287},
  {"lane_id": "RDU-RDU", "origin": "RDU", "destination": "RDU", "input_miles": 103},
  {"lane_id": "WGO-WGO", "origin": "WGO", "destination": "WGO", "input_miles": 422},
  {"lane_id": "BWI-BWI", "origin": "BWI", "destination": "BWI", "input_miles": 433},
  {"lane_id": "JAX-JAX", "origin": "JAX", "destination": "JAX", "input_miles": 464},
  {"lane_id": "GSP-GSP", "origin": "GSP", "destination": "GSP", "input_miles": 275},
  {"lane_id": "MDT-MDT", "origin": "MDT", "destination": "MDT", "input_miles": 688},
  {"lane_id": "MOB-MOB", "origin": "MOB", "destination": "MOB", "input_miles": 749},
  {"lane_id": "BOS-BOS", "origin": "BOS", "destination": "BOS", "input_miles": 799},
  {"lane_id": "CLT-CLT", "origin": "CLT", "destination": "CLT", "input_miles": 235},
  {"lane_id": "WGO-WGO", "origin": "WGO", "destination": "WGO", "input_miles": 434},
  {"lane_id": "PHL-PHL", "origin": "PHL", "destination": "PHL", "input_miles": 528}
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;^ This is from 'Set variable1'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 16:56:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4143367#M5329</guid>
      <dc:creator>PWTRyanWhite</dc:creator>
      <dc:date>2024-09-10T16:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: The execution of template action 'MainForEach1' failed: the result of the evaluation of 'foreach'</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4143845#M5335</link>
      <description>&lt;P&gt;&lt;FONT&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="660529" data-lia-user-login="PWTRyanWhite" class="lia-mention lia-mention-user"&gt;PWTRyanWhite&lt;/a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the screenshot you provided, the error message for Set Variable2 indicates that the expression type you used in the "Set Variable2" step was a string, but the field expected an object type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your current expression returns a string, you can try using the json() function to convert the string into an object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose the expression you use in "Set Variable2" is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;@variables('Variable1')
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try changing it to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;@json(variables('Variable1'))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The process might look something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set Variable1 stores JSON data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;@json(
'[
{"lane_id": "SEA-MFR", "origin": "SEA", "destination": "MFR", "input_miles": 688}, 
{"lane_id": "GSP-GSP", "origin": "SEA", "destination": "GSP", "input_miles": 287}
]'
)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Set Variable2 processes or converts data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;@json(variables('Variable1'))&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 01:54:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4143845#M5335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-11T01:54:00Z</dc:date>
    </item>
    <item>
      <title>Re: The execution of template action 'MainForEach1' failed: the result of the evaluation of 'foreach'</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4145432#M5355</link>
      <description>&lt;P&gt;Unfortunately, after changing to the&amp;nbsp;Anonymous&lt;/a&gt; format, I am getting this error:&amp;nbsp;The variable 'mind_SYMBOL' of type 'String' cannot be initialized or updated with value of type 'Array'. The variable 'mind_SYMBOL' only supports values of types 'String'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW, not sure if I sent you what the variable setup looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 16:20:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4145432#M5355</guid>
      <dc:creator>PWTRyanWhite</dc:creator>
      <dc:date>2024-09-11T16:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: The execution of template action 'MainForEach1' failed: the result of the evaluation of 'foreach'</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4145574#M5356</link>
      <description>&lt;P&gt;Found a resolution using parameters and introducing it directly to the copy activity. No need for more energy on this ticket.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2024 18:26:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4145574#M5356</guid>
      <dc:creator>PWTRyanWhite</dc:creator>
      <dc:date>2024-09-11T18:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: The execution of template action 'MainForEach1' failed: the result of the evaluation of 'foreach'</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4145833#M5358</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="660529" data-lia-user-login="PWTRyanWhite" class="lia-mention lia-mention-user"&gt;PWTRyanWhite&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for sharing, if you have any questions, please continue to let us know in the forum!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 00:54:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/The-execution-of-template-action-MainForEach1-failed-the-result/m-p/4145833#M5358</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-09-12T00:54:43Z</dc:date>
    </item>
  </channel>
</rss>

