web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

desactivate the add of multiple product on crm

(0) ShareShare
ReportReport
Posted on by

Hello 

I would like to desactivate the add of multiple product on a crm opportunité .

any suggestion  ? 

I have the same question (0)
  • Suggested answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    Hi, 

    You can deactivate this feature in the Product Catalog Settings: 

    7870.product-catalog-setting.png

  • Community Member Profile Picture
    on at

    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 ?

  • Suggested answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    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.

  • Community Member Profile Picture
    on at

    any other solution ?

  • Suggested answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    Hi, 

    You can use alternate keys: 

    https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/customize/define-alternate-keys-reference-records

    2308.alternate-key.png

    you will get something like: 

    5504.pending.png

    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: 

    https://community.dynamics.com/crm/b/passiondynamics/posts/alternate-key-creation-stuck-on-pending-status

  • Community Member Profile Picture
    on at

    hi sorry for disturbing but does the first solution desactivate this bottom the + 5466._2B00_.PNG

  • Suggested answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    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/

  • Community Member Profile Picture
    on at

    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 :(

    3513.testtesttest.PNG

  • Suggested answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    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.

  • Verified answer
    meelamri Profile Picture
    13,218 User Group Leader on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 60 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 43

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans