Register to attend – https://k-mug.net/events/dotnet-conf-2022-k-mug/
Power Automate: POST a file to trigger a HTTP flow and upload to SharePoint
My use case here was to store the resumes uploaded by candidate in a website directly in a SharePoint list.
Below is the high level flow the process, created in Power Automate (same you can do in Azure Logic Apps as well with similar steps)
Here is the output, i.e., data and file uploaded to SharePoint/Office 365
The HTTP call is expected to be made from the external application such as a web page but for the purpose of testing, here is the Postman screen used:
Detailed flow
Let us start with an HTTP Request Trigger. You will get a URL which looks like in the below screenshot. This is the URL you will be using. By default this will be using anonymous auth, but you can secure it using few methods, like this one.
Parsing Json
This is an optional step. I wanted to pass some parameters also in addition to the file upload, but I chose not to send individually but as a json string. Since it is a Json string, I have to parse it to extract values from it.
This is the sample input I have. Refer to postman screenshot above.
{
"position": "Java Developer",
"firstname": "Praveen",
"lastname": "Nair",
"email": "praveennnn@abcdef.com",
"phone": "+9715555555",
"urls": ["http://www.google.com", "https://www.adfolks.com"]
}
Create SharePoint List row
Creating a list row and attaching the file is a two step process. First we have to create the row, then using that ID, we have to attach the uploaded file.
Final notes
The last send-mail component you see is just to notify someone in recruitment team that there is a job application logged in SharePoint. Same you can achieve using SharePoint notification features so you may ignore it.
I found that getting filename from the uploaded payload is not so straightforward in Power Automate (someone correct me if I am wrong), but anyways I did’nt need that because the logic I had to use here is to create a custom filename using the candidate’s name and adding the extension we get from the content-type.
TypeScript: Creating a date filter to show ‘days ago’ in ag-grid
Though I’ve wrote this function for Angular – ag-grid, this can be used as an independent method as well.
Code:
LastUpdated(value: string):string {
let inputDate = new Date(value);
let today = new Date();
let yesterday = new Date(today.setDate(today.getDate()-1));
let numdays = Math.round((today.getTime() - inputDate.getTime()) / (1000*3600*24));
let ret:string = formatDate(inputDate,"MMM, dd yyyy",'en-US', '+4');
if ( inputDate.setHours(0,0,0,0) == new Date().setHours(0,0,0,0)) {
ret = "Today";
} else if ( inputDate.setHours(0,0,0,0) == (yesterday.setHours(0,0,0,0))) {
ret = "Yesterday";
} else if (numdays >= 1 && numdays < 7) {
ret = numdays.toString() + " day" + ((numdays > 1)?'s':'') + " ago";
}
return ret;
}
Angular–ag-grid : how to format a date column?
While you will find multiple solutions for formatting a date in ag-grid on internet/stackoverflow and documentation, here is one method I found handy:
{ field: ‘DateUpdated’, valueFormatter: params => formatDate(params.value, ‘MMM, dd yyyy’, ‘en-US’) }
Facing a CORS issue with .NET Core Web API? try this
Read in detail here – https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-7.0
Disclaimer: this is an unethical practice so this is recommended only for development/debugging purpose
Angular-.NET knowledge refresh
Ok, last week I was on an Angular+.NET Core learning spree, and I had to continue since my goals were not met.
- Monday – Angular foundation
- Tuesday – Angular foundation cont. – services, .NET Core Web API setup, EF Core
- Wednesday – continue same… had issues to debug
- Thursday – replaced bootstrap with ng-bootstrap, for no reason
- Friday – continues ng-bootstrap wars, and unhappy. Decides to learn Angular Material after reading UI library comparisons
- Saturday, Today – continues with Angular Material
Dubai Event: Azure ML and Infra deployment–join
Attend this in-person event in person, or online on 8th September 6:30 UAE time.
Launching an App Dev Meetup group for Technology enthusiasts in UAE
Please join the meetup to get the updates. Currently the meetup is in team formation mode and, soon we will announce our first meetup.
https://www.meetup.com/emirates-app-dev-community/
Emirates App Dev Community
Automating Bayzat leave calendar to post daily list in Microsoft Teams group
I was wondering if I can have a feature to post who-are-all-on-planned-leave list daily in the HR/leaders group in Microsoft Teams. Searched for a plugin in the marketplace, and tried to find a API also. Finally, contacted the Bayzat support and found they don’t have a developer API available at the moment. Then I went though the normal HTTP calling methods and found it worked well. Sharing with you, hoping someone will find this useful in future.
Here is the Adaptive Card output you get in Teams:
This is the high level view of the Power Automate App Flow
Details:
Step 1 – Get the authentication access token
This token is required for you to get access to any APIs/URLs. Use the login API for this:
Step 2 – Read the Leave Calendar
My requirement is only to read one single day, so I am passing utcNow()
Step 3 – Modify the response data as per your requirement
My requirement is small that, I need only list of people marked OOO for this particular day
Step 4 – Post to Microsoft Teams
I chose to post the data in Teams as an Adaptive Card, so I am posting in that format
Contact me if you need some clarifications. Make sure to add sufficient validations to make this flow error free.