Hello
I would like to desactivate the add of multiple product on a crm opportunité .
any suggestion ?
hi , thanks this was very helpfull , it actually solved the problem
Hi,
please check this sample code:
protected override void ExecuteCrmPlugin(LocalPluginContext localContext) { if (localContext == null) { throw new InvalidPluginExecutionException("localContext"); } IPluginExecutionContext context = localContext.PluginExecutionContext; IOrganizationService service = localContext.OrganizationService; ITracingService Logs = localContext.TracingService; Entity opportunityProduct = (Entity)context.InputParameters["Target"]; EntityReference product = opportunityProduct.GetAttributeValue("productid"); EntityReference opportunity = opportunityProduct.GetAttributeValue("opportunityid"); // Define Condition Values var QEopportunityproduct_opportunityid = opportunity.Id.ToString(); var QEopportunityproduct_productid = product.Id.ToString(); // Instantiate QueryExpression QEopportunityproduct var QEopportunityproduct = new QueryExpression("opportunityproduct"); // Add all columns to QEopportunityproduct.ColumnSet QEopportunityproduct.ColumnSet.AllColumns = false; // Define filter QEopportunityproduct.Criteria QEopportunityproduct.Criteria.AddCondition("opportunityid", ConditionOperator.Equal, QEopportunityproduct_opportunityid); QEopportunityproduct.Criteria.AddCondition("productid", ConditionOperator.Equal, QEopportunityproduct_productid); EntityCollection result = service.RetrieveMultiple(QEopportunityproduct); if (result.Entities.Count > 0) { throw new InvalidPluginExecutionException("Error, duplicate product"); } }
The plugin will be registered at the creation of the product in preoperation.
Sorry, I misunderstand your requirement. The only way is to use some code. You can use a plugin in the server side or a JS code to Hide the + button if the subgrid contain an element.
i actually tried this solution the key is activated but i do not see any result im still able to create duplicated and many product but i cannot see the job related this fields is empty :(
No problem !
I understand more your requirement. You need a simple JavaScript Code as a custom enable rule in ribbon workbench. Basically, you need to show the + button if the subgrid is empty. Hide the + button if the subgrid contain an element.
Take a look at this example:
https://www.inogic.com/blog/2017/01/hide-add-button-on-a-subgrid-by-applying-custom-javascript-rule/
hi sorry for disturbing but does the first solution desactivate this bottom the +
Hi,
You can use alternate keys:
you will get something like:
Wait until the status change to Active.
If the status doesn't change, and gets stuck on "Pending", please refer to this blog to solve the problem:
any other solution ?
I believe that you need a plugin for this scenario. Basically, the plugin will be executed when a product is added to an opportunity in a preOperation. You can raise an exception if it's a duplicate product.
hi thanks for your answer.
i actually iwant to keep the add of products but for different product, so the sales cannot add the same product twice .
is that possible ?
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Muhammad Shahzad Sh...
106
Most Valuable Professional
Eugen Podkorytov
102