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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
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

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    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

  • Community Member Profile Picture
    on at

    HI A.Sam,

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

    Regards,

    Krishna Shahapur

    Dynamics 365 Developer

  • Suggested answer
    Community Member Profile Picture
    on at

    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.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    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
    BadrinathB Profile Picture
    970 on at

    This may help.

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

  • z.sam Profile Picture
    299 on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans