Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Disable product line items in opportunity after a specific field value is set

Posted on by 299

Hi there everyone, 

Does anyone know how can I disable the opportunity products Grid on opportunity after a value of a field is set to something.

can I do it with business rules or a plug-in has to be written.

*This post is locked for comments

  • z.sam Profile Picture
    z.sam 299 on at
    RE: Disable product line items in opportunity after a specific field value is set

    JavaScript is not recommended,

    Workflow didn't work for me,

    So can anyone tell me how can I make it read-only after the value of a field is set to XXX.

    or ,

    how can I remove the '+' from the grid so that no records are added, and also be able to make the list of records in the grid not editable?

    Rather doing it with a plugin?!

    Regards

  • Suggested answer
    BadrinathB Profile Picture
    BadrinathB 970 on at
    RE: Disable product line items in opportunity after a specific field value is set

    This may help.

    crmbusiness.wordpress.com/.../crm-2013-disabling-a-subgrid

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Disable product line items in opportunity after a specific field value is set

    Hi,

    You could write the following javascript code to achieve this functionality.

    function DisableSubgridsOnFieldValueSet() {
        //Get the field value
        var value = Xrm.Page.getAttribute("fieldName").getValue();
    
        //Get the subgrid control
        var subGrid = Xrm.Page.ui.controls.get("SubGridName");
        
        // If subgrid is not loaded yet, then call same function after some time.
        if (subGrid == null) {
            setTimeout(DisableSubgridsOnFieldValueSet, 1000);
            return;
        }
    
        if (value != null) {
            debugger;
            subGrid.setDisabled(true);
        }
    }

    Hope this helps.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disable product line items in opportunity after a specific field value is set

    The easiest way to achieve this is to create a real time workflow checking opp. product opportunity lookup value.

    When the opportunity.xxx field = xxx, cancel the workflow, then the error will be shown to the users (to prevent user creating any opp. product and associate to the opportunity)

    JS is not the full proof option as user might still be create opp. product via quick view, advanced find or any other options.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disable product line items in opportunity after a specific field value is set

    HI A.Sam,

    Write the javascript, on the particular field value set you can disable the Tab/Section.

    Regards,

    Krishna Shahapur

    Dynamics 365 Developer

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Disable product line items in opportunity after a specific field value is set

    The only way to enforce this would be a plugin on the opportunityproduct entity, which would check the field and throw an exception if a user tries to create or update an opportunityproduct.

    The only other option I can think of would be to convert the opportunity to a quote, and change the quote status, but that might interfere with other processes

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans