当结果集在逻辑应用程序中有一条记录时,Foreach不支持 [英] Foreach not supporting when the result set has one record in logic apps
问题描述
我必须从XML读取数据并将其加载到SQL.因此,在中间,我需要为我用于Logic Apps中的每个任务的每个记录添加一些业务逻辑.但是,当XML中只有一条记录时,结果将被视为对象而不是数组,并且逻辑应用程序将失败
I have to read data from an XML and load it to SQL. So in middle I need to add some business logic for each record for which I used for each task in Logic Apps. But when there is a single record in the XML, result is being considered as Object rather than array and logic app fails
这是我的XML外观:
<VDSP_INPUT_A_Set><VDSP_INPUT_A_Record><head><blanket_number>CMC741311</blanket_number></head></VDSP_INPUT_A_Record></VDSP_INPUT_A_Set>
每个逻辑: VDSP_INPUT_A_Set.VDSP_INPUT_A_Record
即使XML中有一条记录,也需要执行Foreach循环
Foreach loop needs to executed even if there is one record in XML
推荐答案
对于此问题,我进行了一些研究.我将xml转换为json,虽然下面只有一条记录,但结果json将是{键/值对},而不是[array].因此,如果我们使用此值填写每个",则操作将失败.我认为这个问题是由设计引起的.
For this issue, I did some research. I convert the xml to json, while there is only one record under , the result json will be {key/value pair} but not [array]. So if we fill in For each with this value, the action will fail. I think this issue caused by design.
要解决此问题,我认为我们可以在下方添加特定记录,例如:
For a workaround, I think we can add a specific record under , for example:
<VDSP_INPUT_A_Set>
<VDSP_INPUT_A_Record>
<head>
<blanket_number>CMC741311</blanket_number>
</head>
<head>
<blanket_number>specific_test</blanket_number>
</head>
</VDSP_INPUT_A_Record>
</VDSP_INPUT_A_Set>
然后在对于每个动作"中添加一个condition(If)动作,以确定它是否等于"specific_test".
And then add a condition(If) action in For each action to determine if it is equal to "specific_test".
如果为true:请插入sql
If true: do insert sql
如果为假:什么都不做
这篇关于当结果集在逻辑应用程序中有一条记录时,Foreach不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!