Logic App (Read EmailID from database and send email) - azure

Suppose I have two rows in a SQL table, with columns as Email,Record1,Record2.
Now if 'xyz#outlook.com' has two rows in table,
Email|Record1|Record2
xyz#outlook.com|Test1|Test2
xyz#outlook com|Test3|Test4
How can I send email to 'xyz#outlook.com', with 'Email Body' as , all the rows belong to that email ID.
Note: I need to read "To' in Email as dynamic value only
Table:
Email. Record1. Record2
xyz#outlook.com. Test1 Test2
xyz#outlook.com. Test3. Test4
A single email should be send to xyz#outlook com, with details in both the rows.

Please refer to my sample below:
I have a table(named "Emails") in sql like below screenshot:
In logic app, I created an action "Get row(V2)" to get one row of the table.
Then you can use the expression substring(body('Get_row_(V2)')?['email'], 0, indexOf(body('Get_row_(V2)')?['email'], '|')) to get the email address xyz#outlook.com from xyz#outlook.com|Test1|Test2.
============================Update=============================
For the update of your description, pleas refer to my sample.
I have a table like below screenshot:
In logic app, I use "Get rows(V2)" to get the rows of the table.
Then use the expression body('Get_rows_(V2)')?['value'][0]?['email'] as the value of To field when send email.
And in the Body of send email, use four expressions:
body('Get_rows_(V2)')?['value'][0]?['Record1']
body('Get_rows_(V2)')?['value'][0]?['Record2']
body('Get_rows_(V2)')?['value'][1]?['Record1']
body('Get_rows_(V2)')?['value'][1]?['Record2']

Related

How to send the output values of a Lookup activity in an email in Data Factory?

I'm trying to send a LookUp activity output values as part of a body parameter in a POST request using LogicApp, which uses three parameters: "to", "email_body", "subject".
The LookUp activity depends on a query, and it may return from 2 rows up to 10 rows.
According to Azure, the output of the activity should look like this:
{
"count": 2,
"value": [
{
"column1":value1,
"column2":value2,
"column3":value3
},
{
"column1":value4,
"column2":value5,
"column3":value6
}
]
}
In this case, the query returned 2 rows, but how can I attach every output value to the POST body without having to use #activity('lookup_act').output.value[0].column1 and so on for every value?
The POST body is the following:
{
"email_body": "Hi, the following tables have been updated:
#{activity('lookup_act').output.value[0].column1}
#{activity('lookup_act').output.value[1].column1}",
"subject": "Update on tables",
"to": "email#domain.com"
}
I've tried using #activity('lookup_act').output.value to bring every value but it won't work.
Is there a way to call every single output value? If so, how can it be done and paste into a table?
Thanks beforehand.
There are two ways to get all values in mail:
1. Get whole lookup output array in mail.
First get the results from Lookup activity and then pass the output of this activity by converting it into a string otherwise you will get error regarding deserialization.
{"message":"#string(activity('Lookup1').output.value)",
"dataFactoryName":"#{pipeline().DataFactory}",
"pipelineName":"#{pipeline().Pipeline}",
"receiver":"#{pipeline().parameters.receiver}"}
OUTPUT
2. Get all the respective values column wise.
First get the results from Lookup activity then take a foreach loop and create append variable for every column to store every column value in single array.
ForEach activity setting:
Took append variable activity and created Idarray variable. and gave item().id as value to store all id values in a single array.
Then in web activity passed below body for getting all arrays.
{"message":"#{string(variables('Idarray'))} as Id, #{string(variables('Namearray'))} as Name, #{string(variables('ProfessionArray'))} as Profession",
"dataFactoryName":"#{pipeline().DataFactory}",
"pipelineName":"#{pipeline().Pipeline}",
"receiver":"#{pipeline().parameters.receiver}"}
OUTPUT

Concat dynamic value and static text on the FromEmail sender profile

Let's say I would like to setup the FromEmailAddress of the sender profile with both dynamic value and static text. The FromEmailAddress would contain two parts : the account name which is dynamic and a static text '#email-3Dagency.com'. Here is an example of the output I would like for the Account named 'Digital Print' : DigitalPrint#email-3Dagency.com
The value of the field 'Account name' is filled by Salesforce Data when the journey runs. Indeed, account name is a data entry for the journey and the value comes from Salescloud. The account name is always filled in SF.
I had tried to create this Ampscript code in the from email field in the sender profile but the email is not sent when I run the journey:
%%[ set #fromemail = CONCAT(#accountname, "#email-3Dagency.com") set #accountname = AttributeValue("Account:Name") endif ]%% %%=v(#fromemail)=%%
Do you know how I can resolve the issue and if the code above is accurate ?

Get SharePoint User by Lookup ID using Microsoft Graph

I perform the following query in Microsoft Graph:
var results = await SPLists["<my-list-name>"]
.Items
.Request()
.Expand("fields")
.GetAsync();
It gets the list items of a list I have in SharePoint. One of the columns in that list is of type "Person or Group". In the response from Microsoft Graph, it returns that column data like this (for example):
{
"LookupId": 335,
"LookupValue": "John Doe"
}
How do I take advantage of this data? How do I get the full profile of person with ID 355 using the Microsoft Graph? I need the email address of the person returned. How do I get that using the Microsoft Graph SDK?
The Look Id 335 is the Id in the SharePoint Hidden List named "User Information List", you can get the list guid using the request:
https://graph.microsoft.com/v1.0/sites/site-id/lists?$filter=DisplayName eq 'User Information List'
Then use the list guid in the endpoint below to get the detail email address:
https://graph.microsoft.com/v1.0/sites/site-id/lists/UserInformationListId/items/335
Here is a similiar thread for your reference:
How to get user from User field LookupId

Google Form Search and Pull Spreadsheet Data

Hi I have google spreadsheet that contains customers' ID and their shipping status. I want to create google form where customers are able to input each of their own ID, with the return that the google form shows their shipping status.
I tried to look for solutions in internet but there was no luck. I am not really good in programming, i hope there is answer to this problem without having me to do some hard programming.
The sample case can be seen in here: https://docs.google.com/spreadsheets/d/14vSAeZxEJTzbNLLYEiref6qt-CMqiVi8alheLcIBugM/edit?usp=sharing
Google form should show something a little bit like is shown in cell D1:E3.
Where customers can fill the form with their own customer id, and the google form shows the status.
Consideration
There is no way to respond back in a Google Form directly. You can't show custom validation messages after From submission either.
Proposed solution
What about using email addresses additionally to the customerID to retrieve the shipping status? In this way you can easily build a notification system that will send an email if a matching customer ID is found in your spreadsheet.
To build such system you will have to build a Form with a Trigger.
It is required a bit of programming but I will try to cover the most important parts the best I can:
Adapt your Database structure
Add the customers email addresses in the column C in order to be able to retrieve it using the same customer ID.
| A | B | C |
|----+--------+-------|
| ID | STATUS | EMAIL |
Build the Form Trigger
In the Form you are using click on the 3 dots from the top menu and select Script Editor. Here you will write the code that will power your notification system.
function installTrigger() {
// This function instructs the program to trigger the checkID function whenever a form response is submitted
ScriptApp.newTrigger('checkID')
.forForm(FormApp.getActiveForm())
.onFormSubmit()
.create();
}
function checkID(e) {
// This function will parse the response to use the customer ID to retrieve email address and shipping status from the Spreadsheet Database
var responses = e.response.getItemResponses(); // Gets the form responses
var id = responses[0].getResponse(); // Assuming the first answer (index 0) is the customer ID)
var found = SpreadsheetApp.openById('spreadsheet_id')
.getRange('Sheet1!A1:C8') // The spreadsheet cells range in A1 Notation
.getValues() // Retrieve their values in rows
.filter((row) => row[0] == id); // Filter the rows for the provided customer ID
if (found) {
var status = found[0][1]; //Column B
var email = found[0][2]; //Column C
var subject = "Shipping Status";
var message =
`Hello!
The status of the order number ${id} is: ${status}.`
MailApp.sendEmail(email, subject, message);
}
}
Install the trigger
From the Script Editor top menu run the installTrigger() function: Run>Run function>installTrigger.
You are done
Following these steps you have successfully set up the notification system. Now you can start sharing the Form link and accept responses.
References
Installable Triggers
Mail App

How can I set a formula to return "X", when 3 conditions are not matching?

I'll try to be specific. In the attached reference trix (Google sheet), there are 3 sheets,
Login Sheet- where an email address, logs in on a certain date
Schedule- schedule of the email address, for a week
Attendance- where I want the attendance to be marked automatically, based on the inputs on "Login Sheet"
So far, I've managed to do the following (with many help which I received here):
Check if the email address is on Leave/Off (in the Schedule sheet) - Then return- Leave/Off
Check if an email is logged in ("login" in the Login Sheet) on a particular date - Then return "Present"
Here is where I'm stuck and need help -
When an email is scheduled but not logged in - As of now it shows #N/A'no match' (refer to D5,D6 within Attendance), I want this to return "Absent"
Here is the formula I've used so far:
=Ifs(Vlookup($A2,Schedule!$A:$E,4,0)="Leave","Leave",Vlookup($A2,Schedule!$A:$E,4,0)="Off","Off",countifs('Login response'!$D:$D,D$1,'Login response'!$B:$B,$A2,'Login response'!$C:$C,"login")>0,"Present")
The Reference Sheet
You can add another condition in your function to check for absence
replace your function from
=Ifs(Vlookup($A2,Roster!$A:$E,4,0)="Leave", "Leave",
Vlookup($A2,Roster!$A:$E,4,0)="Off", "Off",
countifs('Login response'!$D:$D,D$1,'Login response'!$B:$B,$A2,'Login response'!$C:$C,"login")>0,"Present"
)
To
=Ifs(Vlookup($A2,Roster!$A:$E,4,0)="Leave", "Leave",
Vlookup($A2,Roster!$A:$E,4,0)="Off", "Off",
countifs('Login response'!$D:$D,D$1,'Login response'!$B:$B,$A2,'Login response'!$C:$C,"login")>0,"Present",
countifs('Login response'!$D:$D,D$1,'Login response'!$B:$B,$A2,'Login response'!$C:$C,"login")=0,"Absent",
)

Resources