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 :
Customer experience | Sales, Customer Insights,...
Answered

Filter subgrid value in Unified Interface

(0) ShareShare
ReportReport
Posted on by 828

Hi Everyone, 

 i need to enable or disable a field based on  the value added in sub-grid. 

Example: If i  add a value in product sub-grid as cisco, then i need to hide a field. 

what is the best approach to acheive this. 

Any suggestion are appreciated. 

I have the same question (0)
  • Emily Zhang Profile Picture
    on at

    You can do this by client side scripts. 

    On the form editor -> double click the subgrid -> add event handler. 

    pastedimage1572854917941v2.png

  • cloflyMao Profile Picture
    25,210 on at

    Hi Ram,

    You could add your logic inside the Subgrid OnLoad event, fire the subgridOnchange function at form onLoad event.

    Code below is when any contact record is added/removed, then it will tell user current total rows in account's contact subgrid.

    function subgridOnchange(execContext) {
      var totalRows = "";
      var formContext = execContext.getFormContext();
      var subgridObject = formContext.getControl("Contacts");
      var myContactsGridOnloadFunction = function() {
        // totalRows = subgridObject.getGrid().getRows().getLength();
        // alert(totalRows);
    
        // perform your logic
      };
      subgridObject.addOnLoad(myContactsGridOnloadFunction);
    }
     

    When there is any item be added/removed from subgrid, your function will be executed.

    Regards,

    Clofly

  • Suggested answer
    RamKumarb Profile Picture
    828 on at

    Thanks for your answers.

    @emily we dont have these option for subgrid in unified service.

    @clofly  your code works fine to fetch the count. i would be glad if we can get the value or name of the object added in subgrid.

    I used the below code but coudnt get the values.

    subgridObject.getGrid().getRows().get(1).getData()   //not working

  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    As @emily already provide you to direction of code but the thing you do wrong here is when you enter the product in subgrid if it is the first record in subgrid then you can access these records in 0th index.

    like subgridObject.getGrid().getRows().get(0).getData();

    For more brief look this forum you can easily get the ATTRIBUTE value from the subgrid  too for check weather these product is cisco or not

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/212977/get-rows-in-a-subgrid-and-updating-field-on-form

    Hope it helps

  • Verified answer
    cloflyMao Profile Picture
    25,210 on at

    Hi Ram,

    > You can get a specific row record by(make sure that the attribute/field is available in subgrid):

    subgridObject.getGrid().getRows().get(i).getData().getEntity().attributes.getByName("fullname").getValue();

    > You can get the last row record by(add check condition when total count is 0):

    subgridObject.getGrid().getRows().get(totalRows - 1).getData().getEntity().attributes.getByName("fullname").getValue();

    Regards,

    Clofly

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans