Hello, Would it be possible to hide records based on a field value?, I have a user who must only access records that contains a certain product.
Hello, Would it be possible to hide records based on a field value?, I have a user who must only access records that contains a certain product.
If your registering your plugin in post operation, you need to change your code as below,
EntityCollection leadColl = (EntityCollection)context.OutputParameters["BusinessEntityCollection"];
instead of
QueryExpression leadquery= (QueryExpression)context.InputParameters["Query"];
Yes, I tried also doing it on Post Operation to see if it fixes it but still no luck
Plugin registered in Synchronous, Pre Operation right ?
Yeah I already debugged it , no error whatsoever
If your view is for displaying LEAD records, your code should work. Did you try debugging it ? Do you get any error on loading view ?
Not on subgrid but on System Views, For now I only need it on leads
You're trying to execute this plugin in subgrid which contains LEAD records ? Can you please mention your requirement with exact entity names ?
I have registered the plugin but its not working. Here is my code for reference.
Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)
serviceProvider.GetService(typeof(Microsoft.Xrm.Sdk.IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Query") && context.InputParameters["Query"] is QueryExpression)
{
QueryExpression leadquery= (QueryExpression)context.InputParameters["Query"];
if (leadquery.EntityName == "lead") // Add your entity logical name
{
if (context.UserId == new Guid(userguidhere))
{
ConditionExpression condition = new ConditionExpression("new_product", ConditionOperator.Equal, new Guid(productguidhere));
leadquery.Criteria.AddCondition(condition);
}
}
}
As suggested above you could achieve this by plugin only.
Create and deploy plugin on "RetrieveMultiple" message.
Please refer below sample code for reference:
if(context.InputParameters.Contains("Query") && context.InputParameters["Query"] is QueryExpression) { QueryExpression contactQ = (QueryExpression)context.InputParameters["Query"]; if (contactQ.EntityName == "contact") // Add your entity logical name { if (isUserInRole) return; else { //sample code ConditionExpression condition1 = new ConditionExpression("ownerid", ConditionOperator.Equal, context.UserId); ConditionExpression condition2 = new ConditionExpression("statuscode", ConditionOperator.NotEqual, 809020002); contactQ.Criteria.AddCondition(condition1); contactQ.Criteria.AddCondition(condition2); } } }
You can try with Retrieve Multiple plugin.
Get the context as below,
QueryExpression targetQuery = (QueryExpression)context.InputParameters[“Query”];
ConditionExpression condition = new ConditionExpression(“new_product”, ConditionOperator.Equal, {productid});
targetQuery.Criteria.AddCondition(condition);
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,409
Most Valuable Professional
nmaenpaa
101,156