Skip to main content
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

Hide Edit option based on other field value in the form for Sub grid

(0) ShareShare
ReportReport
Posted on by 467

Hi All,

I am using sub grid in D365 Online

I want to disable "edit" option on sub grid based on the other field value in the form.

How can I achieve this.

Regards,

Babu

  • Narendra Sunkara Profile Picture
    467 on at
    RE: Hide Edit option based on other field value in the form for Sub grid

    Hi All,

    All good now

    I used full namespace and function name in Ribbon work bench and my javascript got triggered

    Regards,

    Babu

  • Narendra Sunkara Profile Picture
    467 on at
    RE: Hide Edit option based on other field value in the form for Sub grid

    Hi guys,

    After doing some further research, I came to know that I am using wrong entity(Sorry for confusion)

    Now I changed to correct Entity, but still my JavaScript function is not hitting and I can't hide the "Edit" button

    How to make a function public and how to call it from Ribbon workbench by using full namespace. If you can give me some examples it will be great

    Regards,

    Babu

  • Narendra Sunkara Profile Picture
    467 on at
    RE: Hide Edit option based on other field value in the form for Sub grid

    Thank you both for your replies,

    Here is what I can see when I click on "Edit" button in ribbon work bench

    Any other inputs please, I checked all the above points and looks fine, but still my debugger is not hitting 

    pastedimage1656906261648v1.png

    Regards,

    Babu

  • Ram Prakash Profile Picture
    2,287 on at
    RE: Hide Edit option based on other field value in the form for Sub grid

    Hi,

    1.Check the Command is attached in the Button.

    2.Put Debugger in the JavaScript and check the same weather the function is hitting or not

  • Suggested answer
    Bipin D365 Profile Picture
    28,981 Moderator on at
    RE: Hide Edit option based on other field value in the form for Sub grid

    Hi,

    Can you please check if you have attached command to your button?

    I think you have created new command and added your js code but you will need to attach this command to your button.

  • Narendra Sunkara Profile Picture
    467 on at
    RE: Hide Edit option based on other field value in the form for Sub grid

    Hi

    Thanks for your reply.

    I tried to implement same thing and just added alert in JavaScript, unfortunately I can't see any alert message, I don't know what went wrong any advise what to check

    Regards,

    Babu

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Hide Edit option based on other field value in the form for Sub grid

    Hi Narendra Sunkara,

    You can create an Enable rule by Ribbon Workbench on your Edit button of related table in the subgrid. Please follow the steps:

    1.Load your solution which contains the related table by Ribbon Workbench.

    subgrid:

    pastedimage1656402601196v1.png

    pastedimage1656402636947v2.png

    2. Customise Edit button's command and create an enable rule whose type is custom rule:

    pastedimage1656402998094v6.png

    pastedimage1656402728433v3.png

    3. Create a JS type web resource whose code is like this:

    function getControl(primaryControl){
    	var formContext = primaryControl;
    	var title = formContext.getAttribute("title").getValue();
    	if(title && title == 'FW Support'){
                 return false;
             }else{
                   return true;
             }
    }
    

    4. Select the library in step3 and type the function name:

    pastedimage1656402877287v4.png

    5.Add the Enable rule to command and publish it:

    pastedimage1656402935151v5.png

    Result:

    pastedimage1656403036317v7.png

    Reference:

    xrmdynamicscrm.wordpress.com/.../

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

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#2
Ramesh Kumar Profile Picture

Ramesh Kumar 42

#3
David Shaw_UK Profile Picture

David Shaw_UK 27

Featured topics

Product updates

Dynamics 365 release plans