locked
How can I prevent the user to put the same product twice in a order? RRS feed

  • Question

  • I want to prevent the user from entering the same product more than once when he makes a new offer or order. Is it possible? I am new in CRM customization and havent found something relevant yet.

    Thanks in advance

    Stavros

    Thursday, January 24, 2013 1:24 PM

Answers

  • You can create a plugin to detect the create of the order product record and cancel it if the associated order already has a product of that type.

    IF the UI is your only concern than you could also use javascript and upon onchange of the product lookup on the order product form, detect if the associated order has that product already (e.g. using REST or FetchXml) and then warn the user and clear the lookup field.


    MS CRM Bing'd - http://bingsoft.wordpress.com
    Dynamics XRM Tools CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM 2011 OData Query Designer
    CRM 2011 Metadata Browser
    CRM Forum Guidance

    • Marked as answer by sethgr Thursday, January 24, 2013 1:40 PM
    Thursday, January 24, 2013 1:31 PM
    Moderator

All replies

  • You can create a plugin to detect the create of the order product record and cancel it if the associated order already has a product of that type.

    IF the UI is your only concern than you could also use javascript and upon onchange of the product lookup on the order product form, detect if the associated order has that product already (e.g. using REST or FetchXml) and then warn the user and clear the lookup field.


    MS CRM Bing'd - http://bingsoft.wordpress.com
    Dynamics XRM Tools CRM 4 to CRM 2011 JavaScript Converter Tool
    CRM 2011 OData Query Designer
    CRM 2011 Metadata Browser
    CRM Forum Guidance

    • Marked as answer by sethgr Thursday, January 24, 2013 1:40 PM
    Thursday, January 24, 2013 1:31 PM
    Moderator
  • You can define duplicate-rules to detect if a product is already available. This will show the user a message that there is already a product with this name but you cant prevent the user from saving this product, although its detected as a duplicate.

    If you want to prevent a duplicate to ever be created, you should create a plugin that will be triggered on 'Create product' and which will check, if there is a product already and if thats the case, will throw an exception.

    Thursday, January 24, 2013 1:35 PM