Hello @Saru Thiagarajan and welcome to Microsoft Q&A.
I believe I have a solution that should work, but found a product bug while implementing it.
The idea is to put the t_person table into a cached sink so we can use a cached lookup. A cached lookup lets us do the lookup in-line rather than a separate lookup activity.
Ideally, I would extract and then replace the personID from the greeting, but you have an example with multiple persons, so I must use a different approach.
First I split the greeting, and clean up the brackets. I do this with
regexSplit(GreetingWithID, `(\[\[personID: )|(\]\])`)
"Hi [[personID: 10001]]" => ["Hi ","10001", ""]
Next I want to replace the "10001" with "Mike". I do not want to replace "Hi". So I can do a test isInteger()
. When using a map, #item represents the current thing.
map(regexSplit(GreetingWithID, `(\[\[personID: )|(\]\])`), iif(not(isInteger(#item)), #item, toString(cache#lookup(toShort(#item)).name)))
Lastly I want to join the pieces together. We can use the reduce()
funtion.
toString(reduce(The_map_above, '', #acc + #item, #result))
The bug I'm working on right now is "name" not being found.