Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port: Support iteration for object in ForEach action #3772

Merged
merged 3 commits into from
Jun 18, 2021
Merged

Conversation

Danieladu
Copy link
Contributor

Fixes #3769

Description

Make it possible for Microsoft.ForEach action to traverse its keys and values.

Changes

There is no change while the value of itemsProperty is array.
If the property value is Object, user could use the "index" property to get the current key, and use "value" value to get current value.
For example:
given such object for property dialog.item:

{
  "k1":"v1",
  "K2":"v2"
}

and the action:

{
    "$kind": "Microsoft.Foreach",
    "itemsProperty": "dialog.item",
    "actions": [
        {
            "$kind": "Microsoft.SendActivity",
            "activity": "index is: ${dialog.foreach.index}, and value is: ${dialog.foreach.value}"
        }
    ]
}

The result would be:
index is: k1 and value is v1 and index is: k2 and value is v2

two other object traverse comparison

1. built-in function indicesAndValues

indicesAndValues is same with the above logic.

2. foreach, where and select builtin functions

These three functions would convert the key into "key" property, and convert value into "value" property. And there is no index property.
For example:

foreach(dialog.item, u, concat(u.key, ':', u.value))

Get:

["k1:v1", "k2:v2"]

@Danieladu Danieladu requested review from a team as code owners June 18, 2021 02:57
@Danieladu Danieladu requested review from Stevenic and chrimc62 June 18, 2021 02:57
@coveralls
Copy link

coveralls commented Jun 18, 2021

Pull Request Test Coverage Report for Build 948519520

  • 11 of 11 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.002%) to 85.407%

Totals Coverage Status
Change from base Build 943670693: -0.002%
Covered Lines: 19278
Relevant Lines: 21472

💛 - Coveralls

@joshgummersall joshgummersall merged commit 2bc15c6 into main Jun 18, 2021
@joshgummersall joshgummersall deleted the hond/foreach branch June 18, 2021 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

port: feat: Support iteration for object in ForEach action (#5689)
3 participants