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

Community site session details

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

Hide add new button on a sub grid based on status reason value

(0) ShareShare
ReportReport
Posted on by 285

Hi New to ribbon workbench, I want to Hide custom entity add new "+" button on a sub-grid based on lead status reason custom value = "100,000,002"

Can someone please guide how to achieve this?

Should I just use ribbon workbench? or do I need to load any web resource javascript file?

Thank you in advance.

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Hide add new button on a sub grid based on status reason value

    Hello,

    I believe this post describes your needs - ribbonworkbench.uservoice.com/.../489288-show-or-hide-the-add-new-button-on-form-sub-grid

  • nidnani Profile Picture
    285 on at
    RE: Hide add new button on a sub grid based on status reason value

    Hi Andrew, thanks for sharing that article.

    I looked at the article and need help in understanding step 6, where it says "  Library = <Select the library you added above>" Since new to customizations, I am not sure how to add a library and where?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Hide add new button on a sub grid based on status reason value

    In order to make customization work you have to add a JavaScript webresource to your system and use code similar to the code provided in the article. In this context "library" is the webresource. Check this post on how you can add webresources to the system - www.tutorialkart.com/.../

  • nidnani Profile Picture
    285 on at
    RE: Hide add new button on a sub grid based on status reason value

    hi Andrew, what code should I use for the javascript? is below okay?

    function hideSub(primaryControl)

    {

    var formContext = primaryControl;

    if(formContext.getAttribute("statecode").getValue() == 100000002)

    return true;

    else

    return false;

    }

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Hide add new button on a sub grid based on status reason value

    I'm afraid something is not fully correct with your code because statecode can't have value 100000002. Did you mean statuscode instead?

    In order to use the value of the field in the script - this field has to be present on the form (even in the hidden state).

    Also I would recommend following alteration to your script to make it shorter and fancier:

    function hideSub(formContext)

    {

    return (formContext.getAttribute("statecode").getValue() === 100000002);

    }

  • nidnani Profile Picture
    285 on at
    RE: Hide add new button on a sub grid based on status reason value

    thanks for noticing.. I meant statuscode.

    Andrew i think i messed up. My "Customise Command" option is now grayed out. Below is the screen shot.

    Not sure how to get back to the default state. I closed it and loaded it back but still no change.

    pastedimage1606857162575v2.png

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Hide add new button on a sub grid based on status reason value

    Can you please show the full screenshot of your RibbonWorkBench?

  • nidnani Profile Picture
    285 on at
    RE: Hide add new button on a sub grid based on status reason value

    Found it. The commands are under the commands tab that's why I was not able to edit it.

    Below is the screenshot with the changes I have published.

    Still no luck on hiding add new button when lead status is sold:(

    RWB.PNG

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Hide add new button on a sub grid based on status reason value

    For the function you have to pass the parameter - blog.magnetismsolutions.com/.../getting-dynamics-365-formcontext-from-ribbon-workbench

  • nidnani Profile Picture
    285 on at
    RE: Hide add new button on a sub grid based on status reason value

    Now getting below error in CRM when clicking on Add New Record

    TypeError: Cannot read property 'getRelationship' of undefined

       at OpenLibrary.addNewFromSubGridStandard (test.crm.dynamics.com/.../Main_system_library.js:1:281229)

       at sl.executeFunction (test.crm.dynamics.com/.../app.js

       at sl.execute (test.crm.dynamics.com/.../app.js

       at test.crm.dynamics.com/.../4.js

       at i (test.crm.dynamics.com/.../app.js

       at test.crm.dynamics.com/.../4.js

       at Array.forEach (<anonymous>)

       at test.crm.dynamics.com/.../4.js

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 107 Super User 2025 Season 2

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 89

#3
#ManoVerse Profile Picture

#ManoVerse 58

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans