Friday, July 24, 2015

Filter Home Page Views using Plugins

Hi all,

As per the CRM, Views we can filtered using Filtering criteria to filter it, some of the conditions we cannot achieve in Filtering Criteria, we can achieve this using Plugins.

Create a Step with the message name as RetrieveMultiple


Copy paste the below code and alter the fields based on your conditon. It will trigger on Page Refresh and View Changes

 if (localContext.PluginExecutionContext.InputParameters.Contains("Query") &&
                        localContext.PluginExecutionContext.InputParameters["Query"] is QueryExpression)
                {

                    QueryExpression query = localContext.PluginExecutionContext.InputParameters["Query"] as QueryExpression;
                    query.ColumnSet.Columns.Add("createdon");
                    query.ColumnSet.Columns.Add("createdby");
                    ConditionExpression condition = new ConditionExpression("name", ConditionOperator.Equal,
                        localContext.PluginExecutionContext.UserId.ToString());
                    ConditionExpression condition1 = new ConditionExpression("createdby", ConditionOperator.Equal,
                       localContext.PluginExecutionContext.UserId.ToString());
                    FilterExpression filter = new FilterExpression();
                    filter.AddCondition(condition);
                    filter.AddCondition(condition1);
                    filter.AddCondition(condition2);
                    query.Criteria.Filters.Add(filter);
                    filter.FilterOperator = LogicalOperator.Or;
                }

No comments:

Post a Comment

Day 11 - Customizing Option Sets Dropdown Fields with JavaScript

  In this Blog, we will see how to Customizing Option Sets Dropdown Fields with JavaScript label1 = formContext.getAttribute( "bosch_op...