6 thoughts on “Configure Sub Grid from CRM forms in Dynamics 365 Portal

  1. santosh

    how to get the row count of subgrid in dynamics crm portals.

    1. Inogic


      Here, if you want to get row count of sub grid using script then you can try with below code snippet. You need to add below code in script section of entity form.


      $(document).ready(function () {

      setTimeout(function () {

      var rowCount = 0;

      rowCount = $(“#CONTACTS table tbody tr”).length;


      , 3000);

      In the above code snippet, as portal form takes some time to render sub grid on form you need to add timeout so that it will wait for few seconds and return the count of records present in sub grid. Also, instead of ‘CONTACTS’ you need to provide sub grid name as per your requirement.

      And, if you want sub grid count in liquid code then you can check that by retrieving data of that specific entity using FetchXML. Below is the sample code to retrieve data using FetchXML in liquid.


      {% fetchxml accounts %}
      <fetch version=”1.0″ output-format=”xml-platform” mapping=”logical” aggregate=”true”>
      <entity name=”account”>
      <attribute name=”accountid” alias=”AccountCount” aggregate=”count” />
      {% endfetchxml %}

      {% if accounts.results.entities.size > 0 %}
      Count: {{ accounts.results.entities[0][“AccountCount”] }}
      {% else %}
      No data found.
      {% endif %}

      Note: Suppose at your end the entity permission for respective entity is not present and you did not get data using above code then try by creating entity permission of respective entity.

      For more information please refer the link given below:


      Hope this helps!

  2. Mojahid Ali

    Hi There,
    Other than existing buttons like create, edit etc I want to create different buttons such as Post Survey. This button will be disabled once the survey request is sent. Can I achieve this using OOB subgrid or do we need custom grid for this. Please provide a solution for this. Ex: Pre Survey is a custom button in below screenshot.

    1. Inogic

      Hi Mojahid,

      1. OOB Way: If you have placed OOB Subgrid of any entity which has a custom button on the portal, you can add the filter criteria for that button. Please refer below screen clip:

      2. Custom Code:

      a. Use liquid code In Copy HTML tag in Content Page and write your fetchXML in liquid tag

      Note: Add condition in liquid fetchXML :

      This condition will always fetch the latest data.

      b. Check If the size of the collection is greater than 1, then disable the button using Jquery.

      For e.g. $(‘#btnSurvey).prop(‘disabled’, true);

      Hope this helps!

    1. Inogic

      No, We cannot add the subgrid on the Insert Mode.

      In CRM, we cannot see the subgrid unless we create record even if it is added on the form as linking can only happen with the record already created in the CRM.

      Portal also behaves in same way! We can only see the sub grid in edit mode only and not in insert mode.


Comments are closed.