'How do i get body of message when using keyword mentions in teams
in automate i have a flow. I am using "When keywords are mentioned". the keyword i entered is "test"
I Selected, the team,channel,etc... all correctly.
when someone types "the test is a success". in that channel. how do i get the full string "the test is a success"?
I have tried a few operations "get Messages", also tried a few dynamic content options and a few triggeroutput variations. all either are blank or provide a long json string with subscription,channelId,teamId,etc. but not the string I am trying to get.
Solution 1:[1]
The Get message details action should help you ...
In the body of the response, you'll clearly see the text that was entered to invoke the trigger.
Solution 2:[2]
Use Get message details, you will get message detail of that reply message. Then get your text with expression like this: outputs('Get_message_details')?['body']['body']['plainTextContent']
Solution 3:[3]
SOLVED:
It turns out that the functionRows.Insert was actually pasting the function stored in the clipboard from the previous sub.
I put Application.CutCopyMode = False and it solved my issue.
Thanks
Solution 4:[4]
All those procedures could be combined into one.
Using Select could also open a whole world of hurt if someone accidently changes the active sheet while the code is running.
You also use three or four different methods to find the last row.
Much better to open the workbook and assign it to a variable, then use that reference in your code. Same with the sheets - no need to select it first.
Obligatory link to post: how-to-avoid-using-select-in-excel-vba
With that said, here's a re-write of your code. It's not perfect as I've just followed the order of your procedures, but will hopefully show a better way.
Public Sub Test()
'Covers A_PZ_ZST_INB_MVT()
''''''''''''''''''''''''''
Dim wrkBk As Workbook
Set wrkBk = Workbooks.Open("K:\WAW\Warehouse\ZSMOPL\KomunikatyOS,XML\ZST_INB_MVT.XLSX")
With wrkBk.Worksheets("Sheet1")
'Covers B_PZ_konwertujmaterial() and C_PZ_konwertujilosc()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With .Range("C:C,F:F")
.NumberFormat = "General"
.Value = .Value
End With
'Covers D_PZ_kolumny()
''''''''''''''''''''''
.Columns(1).Insert Shift:=xlToRight
.Columns(10).Insert Shift:=xlToRight
With .Range("J:J")
.NumberFormat = "General"
.Value = .Value
End With
'Covers E_PZ_prawdafalsz()
''''''''''''''''''''''''''
Dim NumRows As Long
NumRows = .Cells(Rows.Count, 4).End(xlUp).Row 'Better to start from bottom and go up.
.Range(.Cells(3, 1), .Cells(NumRows, 1)).FormulaR1C1 = "=RC[2]=R[-1]C[2]"
'Covers F_PZ_kopiujinvoice()... probably a faster way to do this.
''''''''''''''''''''''''''''
Dim LastRow As Long
LastRow = .Cells(Rows.Count, 3).End(xlUp).Row
Dim myRow As Long
For myRow = 1 To LastRow
If .Cells(myRow, 3) = "" And .Cells(myRow + 1, 3) <> "" Then
.Cells(myRow, 3) = .Cells(myRow + 1, 3)
End If
Next myRow
'Covers G_PZ_konwertujinvoice()
'''''''''''''''''''''''''''''''
With .Range("C:C")
.NumberFormat = "General"
.Value = .Value
End With
'Covers H_PZ_usunduplikaty() - probably faster to filter and delete.
''''''''''''''''''''''''''''
For myRow = .Cells(Rows.Count, 5).End(xlUp).Row To 1 Step -1
If .Cells(myRow, 5) = "" Then .Rows(myRow).Delete Shift:=xlUp
Next myRow
'Covers I_PZ_prawdafalsz2()
'''''''''''''''''''''''''''
.Columns(1).ClearContents
NumRows = .Cells(Rows.Count, 2).End(xlUp).Row
.Range(.Cells(3, 1), .Cells(NumRows, 1)).FormulaR1C1 = "=RC[2]=R[-1]C[2]"
'Covers J_PZ_puste_wiersze()
''''''''''''''''''''''''''''
NumRows = .Cells(Rows.Count, 4).End(xlUp).Row
For myRow = NumRows To 1 Step -1
'Not sure what you're doing here.
'Checking if columns A contains False and inserting a row?
If .Cells(myRow, 1) = False Then
.Rows(myRow).Insert Shift:=xlDown
End If
Next myRow
'Covers K_PZ_kopiujinvoice()
''''''''''''''''''''''''''''
NumRows = .Cells(Rows.Count, 3).End(xlUp).Row
With .Range(.Cells(2, 3), .Cells(NumRows, 3))
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[1]C"
.Value = .Value
End With
'Covers L_PZ_kopiujvendor()
'''''''''''''''''''''''''''
NumRows = .Cells(Rows.Count, 2).End(xlUp).Row
With .Range(.Cells(2, 2), .Cells(NumRows, 2))
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[1]C"
.Value = .Value
End With
End With
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Skin |
| Solution 2 | Kia |
| Solution 3 | pepes |
| Solution 4 | Darren Bartrup-Cook |


