PowerApps: Send an email with values of dynamic collection - sharepoint

I have built a Power Apps, with a SharePoint list as data source. The list consist of 4 columns (static, number will be always the same) and several rows (dynamic - items can be added deleted). See below and attached attached
Title / Description / Signature / Kind
Item 1 Title / Item 1 Description / Item 1 Signature / Item 1 Kind
Item 2 Title / Item 2 Description / Item 2 Signature / Item 2 Kind
The purpose is to send an email with values, which are selected in PowerApps.
I have a list, which is viewed in the app as Gallery List and shows only the Titles and Kinds of items. Each item in the app has a check box, which is used for collecting it on "Check" action using Collect function:
Collect(Collection2,ThisItem)
The collection is then previewed in another Gallery List (meant to be not visible), which shows the column values, that I want to send in the email message: values of checked items from "Title, Description, Signature" columns. For the email I use below. "Title3", "Subtitle2" and "Body1" are field identifiers from the Gallery.
Office365Outlook.SendEmailV2(TextInput3,"GCP Agreement Cover letter", Concat(Collection1,
"<b>" & "Agreement title" & "</b>" & "<br>" &
" " & Title3 & "<br>" &
"<b>" & "Agreement Description" & "</b>" & "<br>" &
" " & Subtitle2 & "<br>" &
"<b>" & "Signed by" & "</b>" & "<br>" &
" " & Body1 & "<br>" & "<br>"& "<br>" & "<br>"))
The problem is, that the email does not contain dynamic values, which are checked, but static: the first checked value is replicated to the amount "checked" items (luckily that works). For example, if the first two items are checked:
As is:
Agreement title
Item 1 Title
Agreement Description
Item 1 Description
Signed by
Item 1 Signature
Agreement title
Item 1 Title
Agreement Description
Item 1 Description
Signed by
Item 1 Signature
To be
Agreement title
Item 1 Title
Agreement Description
Item 1 Description
Signed by
Item 1 Signature
Agreement title
Item 2 Title
Agreement Description
Item 2 Description
Signed by
Item 2 Signature
Can anybody help with having correct values in the email message?

If you're trying to filter by checkbox, you can use the Filter() function to select items that just have the checkbox checked. And then Concat() to merge the remaining items into a string.
Concat(Filter(Gallery3.AllItems, ThisRecord.Checkbox1.Value),ThisRecord.SampleText)

Related

Hyperlink formula for sending email in outlook

I am trying to automate a task that's repetitive but I'm aware that hyperlink doens't allow me to copy and paste a range of cells so I'm doing the tedious task of trying to format it correctly but it seems the amount of blank cells in a string is creating too much of a issue. Is there a way to edit it to where I don't have to have so much white space to create the format I need?
I should mention, when I evaluate the formula, it returns everything correctly but then it gets to "Send Email" and I get a #VALUE error.
The goal is to format it into 4 columns and space it out.
(The only reason why I'm using a formula instead of VBA is because the higher-ups do not want VBA due to how sensitive the spreadsheet is.)
=HYPERLINK("mailto:" & F16 & "?subject=Testing" &"&body=" & " Product " & " Agvance Blend Ticket " & " Invoice/ Transfers # " & " Qty " & "%0A"
& CONCATENATE(" ", C5," ",E5," ",F5, " ", G5) & "%0A"
& CONCATENATE(" ", C6," ",E6," ",F6, " ", G6),"Send Email")
If whitespace is the problem, then don't use it; use the Outlook tab character instead, e.g.
=HYPERLINK("mailto:" &F16&"?subject=Testing&body=%09Product%09%09Agvance Blend Ticket%09%09Invoice/ Transfers #%09%09Qty%0A"
&CONCATENATE("%09",C5,"%09%09",E5,"%09%09%09%09",F5,"%09%09%09%09",G5,"%0A")
&CONCATENATE("%09",C6,"%09%09",E6,"%09%09%09%09",F6,"%09%09%09%09",G6),"Send Email")
sample draft email

How to use the match Function with two criteria in VBA

I am trying to use the „MATCH“ function in order to get the Row (named RICRow) number of a name which is contained in the “RIC“ column (A). Because there are always two names in the RIC column (e.g.”Tom”) it is necessary to take the column(L) “RIC_FID” into consideration which contains a unique value corresponding to the names (e.g. 295). The VBA code below keeps yielding the error msg: type mismatch
RICRow = Application.WorksheetFunction.Match(RIC & RIC_FID, protokoll.Range("A1:A500") & protokoll.Range("L1:L500"), 0)
this one solved the issue:
RICRow = protokoll.Evaluate("match(""" & RIC & "" & RIC_FID & """, A:A&L:L, 0)")

Using if statements in the body of email Excel to Outlook

I am lost on how to tackle this part of the project I have undertaken for my company. I have created thus far, code that will filter, search for count of times an item is mentioned, and store it into a variable.
I have 20 of these items and I need to send an email out with the amount of times an item was mentioned.
I would rather just send an email that shows only the items that were mentioned and leave the rest out.
Doing this in Excel is the hard part as I am unsure how to code it in the body. Any help on sending me in the right direction would be greatly appreciated.
EX.
Item 1,
Item 1,
Item 2,
Item 3.
VarForItem1 = 2
VarForItem2 = 1
VarForItem3 = 1
VarForItem4 = 0
VarForItem5 = 0
etc.
I want the email to only show the Vars that have greater than 0.
I figured it out, with a combination of if statements underneath the calculation and a strmessage string. I just added the line with the amount if it was above 0.
If item1 > 0 then
strmessage = strmessage & "Item 1 - " & strmessage & vbnewline
End if

VBA/Excel - Group by value in table and send e-mail

I have a large list where I have different companies and organisations. My current VBA codes iterates through each table row, and send out an e-mail for each line.
However, what I need to achieve is that there might be companies which have the same parent organisation - in this case, I don't want to send out an e-mail for each company, but would rather send out one e-mail to the organisation, including all the associated companies.
I have tried to illustrate it in below table.
So for record #1, I would just send out an e-mail as always. However for [2-3], I would like to send out one e-mail, which includes company name 2 and 3.
Same goes for record [4-6], which should also send out one e-mail, but include company name #4, #5 and #6.
Example:
Hi Organisation B
Please check below companies in your organisation:
Company 2
Company 3
My current code:
Below is my current code, which iterates through all table rows and send out mails:
'Count table rows
Set tbl = oWorksheet.ListObjects("DataTable")
TableRows = tbl.ListRows.Count
TableRows = TableRows + 1 'Skips the header
iRow = 2 'Skip the header
Do While iRow <= TableRows
Set oNotesMail = oMailDB.CreateDocument
oNotesMail.Form = "Memo"
oNotesMail.SendTo = oWorksheet.Cells(iRow, 5).Value
oNotesMail.Subject = "Company check"
oNotesMail.Body = "Hi " & oWorksheet.Cells(iRow, 2) & "Please check"
oNotesMail.SaveMessageOnSend = True
oNotesMail.PostedDate = Now()
oNotesMail.Send 0, oWorksheet.Cells(iRow, 5).Value
Set oNotesMail = Nothing
Loop
So above code send out an email (in Lotus Notes) for each line.
How can I achieve my example above?
Please note
The table will always be sorted by 'Organisation' - hopefully this will help when the code is iterating through the rows.

Split String in Reporting Services expression

I have a free text field that have full name of consultants.
e.g. Smith John
I would like to display in reporting services expression as John Smith.
i want to swap the name around, bring the first name first.
any help.
=Right(Fields!name.Value, Len(Fields!name.Value) - InStr(Fields!name.Value, " "))
& " "
& Left(Fields!name.Value, InStr(Fields!name.Value, " ") - 1)

Resources