Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

Filter subgrid value in Unified Interface

Posted on by 826

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. 

  • Verified answer
    cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Filter subgrid value in Unified Interface

    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

  • Suggested answer
    ajyendra Profile Picture
    ajyendra 1,730 on at
    RE: Filter subgrid value in Unified Interface

    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

  • Suggested answer
    RamKumarb Profile Picture
    RamKumarb 826 on at
    RE: Filter subgrid value in Unified Interface

    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

  • cloflyMao Profile Picture
    cloflyMao 25,198 on at
    RE: Filter subgrid value in Unified Interface

    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

  • Emily Zhang Profile Picture
    Emily Zhang on at
    RE: Filter subgrid value in Unified Interface

    You can do this by client side scripts. 

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

    pastedimage1572854917941v2.png

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans