SharePoint Online: Approval Request via email comment and update response in List

In this article, we are going to discuss the process of creating an approval workflow. We will work on functionality so that the Approver or Manager can approve and reject the request via email instead to navigate webforms. 
Scenario
  1. Employee raises a leave request.
  2. The request goes to the employee manager or whoever is assigned as AD or synced with the O365 account.
  3. Manager can approve or reject the request with comments via email.
  4. The employee will get notified based on the manager comments. 

Prerequisites
  1. Microsoft Flow.
  2. A SharePoint Online list.
  3. Office 365 Outlook and Office 365 Users account.
Let's get started 
The overall Microsoft Flow structure will look like this.




Step1
To create a leave request, I am using a List at SharePoint Online. Employee submits a request and the associated MS Flow gets triggered on item creation.



Step 2
Create a string variable as a name Manager (This step can be optional too).

Step 3
Get user manager from O365 profile using "created by"; i.e., who has created the request. User Manager should be assigned at O365 User Profile.
Set Manager email id to the created variable to send the request.

Step 4
Add an action “Start and Wait for an approval”.
Select the approval type: Approve/Reject – First to respond and assign the request to Manager with title and details.
The advantage of this action is that the workflow will not proceed until the manager approves or rejects the workflow via email body button.

Step 5
Check for condition and accordingly, update the manager comments provided in an email to SharePoint Online List.

Step5.1
If Request status is approved, then update the action. The "Send email" section will look like this.



Step5.2
If the Request status is rejected, then update the action. The "Send email" section will look like this.

Now, we will talk about the flow process.
The user creates a request via form (Created a list at SharePoint Online with a required column for demo purpose). Here, I have created the first request.


The designated Microsoft Flow gets triggered and waits until the request is not responding.



Switch to "manage email" box and check for email. Manager will get an approval email.


Approval of request assigned manager can act over a request with approving or rejecting a request with comments.



As approver responded to an email with comment and approved status. The Leave request item will get updated with a response,


The employee gets a final notification along with the approve/reject status.


I hope you have learned something new in this article. Stay tuned for related articles to get more insights and learning.

MSFlow | Best Practice | Lookup Threshold Issue

Here, we are going to discuss a very common problem statement faced during the runtime of Microsoft Flow:

The query cannot be completed because the number of lookup columns it contains exceeds the lookup column threshold enforced by the administrator.

This problem statement occurs whenever Microsoft Flow executes over SharePoint Online list or library where the Lookup column exceeds the limit of 12 columns. The administrator cannot change the threshold limit at SharePoint Online, either at the Tenant or Site Collection level.





Why does Microsoft set the magic number 12 as the threshold limit?

Reason
Each lookup column creates a join with other tables. So, Microsoft decided to set the limit at 12 to avoid performance degradation.
Let's get started with detailed resolution.
Custom lookup column can be created using the below types.
  1. Standard Lookup column
  2. People Pickers
  3. Managed Metadata
  4. Workflow
  5. Share With
OOTB Lookup columns
  1. Created by (both for List & Library)
  2. Modified by (both for List & Library)
  3. Name (linked to Document)
  4. Link (Edit to edit item)
  5. Name (linked to Document with edit menu)
  6. Type (icon linked to document)
Lookup column is quite useful but we should be cautious about the threshold limit while designing the schema.
I created a list with 13 lookup columns. See the below list for your reference.

Problem statement with Get Items

When we run flow to get an item from a List or Library having more than 12 lookup columns, it throws the following error.

Resolution with Get Items

Create a list or library view with 12 or fewer than 12 lookup columns and set the view at the Get Items action. During a custom View creation, we can ignore the OOTB column or the ones that are not required for this operation.

After setting the list View with 12 lookup columns, once I execute the flow, it succeeds.


Problem statement with Update Item

A similar issue occurs when we want to update the items using MS Flow.


Resolution with Update Item 

I created a View with 12 lookup columns and set “Limit Column by View” with a newly created View.

Once I executed the flow with the View which is having 12 lookup columns, it succeeded and updated the item.
I hope you have learned something new in this article. Stay tuned for related articles to get more insights and learning.

Speaking at C# Corner Annual Conference 2019

Automate the Business Process using AI Services and O365 Suites.




I am very excited to going as speaker at C # corner Annual conference 2019  this Saturday at Delhi 





Address:-
The Leela Ambience Convention , 1,CBD, Near Yamuna Sports Complex,
Maharaja Surajmal Marg, Delhi, 110032



Definitely you folks will learn a good use case for this. 

More 
Annual conference 2019 https://conference.c-sharpcorner.com/
Happy Coding.

Strategy Design Pattern Using .Net (C#)

In this article, we will understand what Strategy Pattern is and when we actually need to use it, along with a practical example and real-life use case.

This pattern falls under the category of behavioral pattern and as the name suggests, it allows clients to choose an algorithm from a set of algorithms at run time.
Strategy pattern defines a family of algorithms, encapsulates each one of them and makes them interchangeable at run time within that family.
Now let's understand what each one of them actually means.


Family of Algorithms
This means this pattern provides a set of algorithms using one of which at run time you can achieve the desired output.

Encapsulate each one of the
This pattern allows you to place your algorithms in different classes (encapsulate them).

Makes the algorithm interchangeable
The beauty with strategy pattern is that we can select at run time which algorithm we want to apply to our object and can also replace them with one another.

These are the three main points of Strategy pattern. I hope we are clear with the above- discussed points. So, let's understand one real -world scenario where it can be really helpful to use.

Example

Suppose you want to order food online and apply one of the available coup. In this case you can implement the Strategy Pattern.

As per our example, IApplyCoupon is the interface which looks something like,​

  • 1.  public interface IApplyCoupon    
  • 2.     {    
  • 3.         string applycoupon(string couponType);    
  • 4.     }   


We have 2 Concrete coupon classes which implement IApplyCoupon interface and these classes can have their own logic to calculate the time.
  1. 1.  public class FamilyHours :IApplyCoupon    
  2. 2.     {    
  3. 3.         public string applycoupon(string couponType)    
  4. 4.         {    
  5. 5.             return "You applied family hours coupon";    
  6. 6.         }    
  7. 7.     }    


  1. 1.  public class FestivalOffer :IApplyCoupon    
  2. 2.   {    
  3. 3.       public string applycoupon(string couponType)    
  4. 4.       {    
  5. 5.           return "You applied festival offer coupon";    
  6. 6.       }    
  7. 7.   }   




Lastly, we have one Context class called TravelStrategy using which a client can select any strategy at run-time.

  1. 1.  public class Coupon    
  2. 2.     {    
  3. 3.             private IApplyCoupon _applycoupon;    
  4. 4.             public Coupon(IApplyCoupon applycoupon)    
  5. 5.             {    
  6. 6.                 _applycoupon = applycoupon;    
  7. 7.             }    
  8. 8.             public void applycoupon(string couponType)    
  9. 9.             {    
  10. 10.                var result = _applycoupon.applycoupon(couponType);    
  11. 11.                Console.WriteLine(result);    
  12. 12.            }    
  13. 13.            
  14. 14.    }    

Our main program looks like:

  1. 1.  class Program    
  2. 2.     {    
  3. 3.         static void Main(string[] args)    
  4. 4.         {    
  5. 5.             Console.WriteLine("Hello!, Please select the coupon for Dinining \n1.FamilyHours \n2.FestivalHours");    
  6. 6.             var userStrategy = Console.ReadLine().ToLower();    
  7. 7.             Console.WriteLine("\nUser has selected " + userStrategy + " as dining coupon\n");    
  8. 8.             switch (userStrategy)    
  9. 9.             {    
  10. 10.                case "FamilyHours":    
  11. 11.                    new Coupon(new FamilyHours()).applycoupon("FamilyHours");    
  12. 12.                    break;    
  13. 13.                case "FestivalHours":    
  14. 14.                    new Coupon(new FestivalOffer()).applycoupon("FestivalHours");    
  15. 15.                    break;    
  16. 16.                default:    
  17. 17.                    Console.WriteLine("You didn't select any coupon");    
  18. 18.                    break;    
  19. 19.            }    
  20. 20.            Console.ReadLine();    
  21. 21.        }    
  22. 22.    }    

OUTPUT

When user selects family hours as the preferred dining coupon




Answer



 2. When user selects festival hours as the preferred dining coupon



Output




Hope you have learned something new in this article, Stay tune for next one.