As in my organization, SPD is not allowed to use and PowerShell as well, I have used console application and CSOM to achieve the same. Below is the code if anyone has same situation:
using System;
using Microsoft.SharePoint.Client;
namespace MyConsoleApplication
{
class Program
{
static void Main(string[] args)
{
try
{
ClientContext clientContext = new ClientContext("Your site URL");
Web web = clientContext.Web;
List list = web.Lists.GetByTitle("Workflow Tasks");
ViewCollection viewColl = list.Views;
// Specify the columns that should be displayed
string[] viewFields = { "Title", "AssignedTo", "Status", "Created" };
string ViewQuery = "@<Where>" +
"<Or>" +
"<Eq>" +
"<FieldRef Name='AssignedTo' />" +
"<Value Type='Integer'>" +
"<UserID />" +
"</Value>" +
"</Eq>" +
"<Membership Type='CurrentUserGroups'>" +
" <FieldRef Name='AssignedTo' />" +
" </Membership>" +
"</Or>" +
" </Where> ";
// Specifies the properties used to create a new list view
ViewCreationInformation creationInfo = new ViewCreationInformation();
creationInfo.Query = ViewQuery;
creationInfo.Title = "AllMyTasks";
creationInfo.RowLimit = 100;
creationInfo.ViewFields = viewFields;
creationInfo.ViewTypeKind = ViewType.None;
creationInfo.SetAsDefaultView = false;
viewColl.Add(creationInfo);
clientContext.ExecuteQuery();
Console.WriteLine("View created success! Press any key to close!");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message.ToString());
Console.ReadLine();
}
}
}
}