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.

image

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’) }

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:

image

This is the high level view of the Power Automate App Flow

image

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:

image

Step 2 – Read the Leave Calendar

My requirement is only to read one single day, so I am passing utcNow()

image

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

image

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

image

Contact me if you need some clarifications. Make sure to add sufficient validations to make this flow error free.

Find the first and second largest number in a series – without using arrays or functions

This is just a revision of my school memories. Language used is Java.





import java.util.Scanner;

public class testmain {
public static void main(String[] args) {

int large = 0; // there is a possible logic error, ignore
int slarge = 0; // there is a possible logic error, ignore

Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number of elements");
int N = scanner.nextInt();

for (int c = 0;c<N;c++) {
int num = scanner.nextInt();

if (num > large) {
large = num;
}

if (num != large && num > slarge) {
slarge = num;
}

}
System.out.println(
"Largest = " + large +
"\nSecond Largest = " + slarge
);
}
}

Power Automate: Send daily bugs report in Microsoft Teams from Azure DevOps Boards

You can simply change same to send a mail notification too, instead of Teams.

Sample output on Teams:

image

Development Steps:

Step 01 – Create query in Azure DevOps board for Bugs

I would start with a Recurrence Trigger (schedule). Check always the Time zone of the trigger will happen on GMT.

Step 01 – Schedule

I would start with a Recurrence Trigger (schedule). Check always the Time zone of the trigger will happen on GMT.

image_thumb[2]

Step 02 – Initialize Azure DevOps URL (optional)

I am using this url for hyper linking in the output, which can be considered optional.

image

Step 03– Get bug list from DevOps boards

I suggest you to create a ‘query’ first which returns filtered ‘bug’ results. Below is the query have created and saved for this example blog.

image

Next, get the results from this query:

image

Step 04 – HTML’ize

I wanted to format the Bugs list content as a table and, MS Teams message supports HTML. So I will create a header and assign it to a new variable.

image

Step 05– Convert rows to HTML rows

Next step creates each row from DevOps boards query to corresponding <TR>s. You can choose to omit or add any columns as per your requirement.

image

Step 06 – Close HTML table

Once the rows are added to HTML table, I would close it and add also any footer notes.

image

Step 07– Post message in Teams

Finally, send the message to Teams. I have used a group chat in my case. Additionally I am using a ‘condition’ component also to check if the list is empty so it can directly ‘terminate’ the flow instead of posting an empty table in Teams.

image

Flow view:

This is what my simple Power Automate flow looks like:

image

Power Automate: Send daily status post in Microsoft Teams from a SharePoint List

Assuming you have a “List” in SharePoint and you want to post a summary/or list as-it-is to a chat group in Microsoft Teams. You can simply change same to send a mail notification too, instead of Teams.

Output in Teams:

image

Development Steps:

Step 01 – Schedule

I would start with a Recurrence Trigger (schedule). Check always the Time zone of the trigger will happen on GMT.

image

Step 02 – Get list items from SharePoint

Choose the site address and list name

image

Step 03 – HTML’ize

I wanted to format the SharePoint List content as a table and, MS Teams message supports HTML. So I will create a header and assign it to a new variable.

image

Step 04 – Convert SharePoint rows to HTML rows

Next step creates each row from SharePoint to corresponding <TR>s. You can choose to omit or add any columns as per your requirement.

image

Step 05 – Close HTML table

Once the rows are added to HTML table, I would close it and add also any footer notes.

image

Step 06 – Post message in Teams

Finally, send the message to Teams. I have used a group chat in my case.

image

Flow view:

This is what my simple Power Automate flow looks like:

image