arraysfilterbotframeworkescapingbot-framework-composer

Filter array by variable in Bot Framework .net


For each item in array1, I want to filter array2 by the array1 item the bot is currently in.

Within an Edit an array property, if I filter array2 hard-coded like so it creates a nice array:

"changeType": "push",
"itemsProperty": "user.array2",
"value": "=where(json(user.apiResponse.content).value,x,x.myKey=='magazine')"

However if I use a dynamic key based on the current item in array1, this doesn't work:

"changeType": "push",
"itemsProperty": "user.array2",
"value":"=where(json(user.apiResponse.content).value,x,x.myKey==concat('\'',json(dialog.forEachThing.value).name,'\''))

I've tried setting a property, user.myFilter and passing that, as below.

"property": "user.myFilter", 
"value": "=concat('\\'',json(dialog.forEachThing.value).name,'\\'')"

And while this user.myFilter evaluates correctly to 'magazine', the Edit an array property/push doesn't get any values.

I'd really welcome any thoughts on where I'm going wrong. I've tried a few things like '''' in user.myFilter but these evaluate as null.


Solution

  • Ok, updated answer here for those who follow.

    Turns out I was wrong. In .Net anyway, the solution is to simply not wrap the variable in single quotes. Thanks to Dana V in github for the heads up.

    It seems that may not work in Javascript however.