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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

Record count in subgrid in web form and do not allow to move next steps in portal

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All,

I have created a web form with 5 steps where 4th and 5th steps have only subrid with create button to create new record. I have a business logic to check whether any record in the subgrid. If the subgid doesn't have any value, then it should display error message and shouldn't allow to move next step. When a count is more than 1, it should allow to move next step. 

Could you please help me with code how this can be done.  

Thank you,

Leo

  • LeoAlt Profile Picture
    16,341 Moderator on at

    Hi partner,

    I suggest that you could try the following way.

    1.Get your subgrid record count in web form with JS code first.

    Please refer to this thread about how to get record count.

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/292653/how-to-get-subgrid-row-count-in-entity-form-partner-portal?pifragment-97030=1

    2.Set the record count to a custom field on the web form or entity form.

    3.Add a condition step and set the condition to if custom field >0.

    Best Regards,

    Leo

  • LeoFernandas Profile Picture
    Microsoft Employee on at

    Hi Leo,

    Thank you very much for this work around. When I added the script given in the blog and did debug the code, I just saw that it didn't go inside the function and it came out of from execution after return statement if (typeof (Page_Validators) == 'undefined') return; ). 


    if (window.jQuery) {
       (function ($) {
           $(document).ready(function () {
    		   debugger;
               if (typeof (Page_Validators) == 'undefined') return; // came our from exectuion after this line
               var newValidator = document.createElement('span');
               newValidator.style.display = "none";
               newValidator.id = "ValidateLeadRecords";          
               newValidator.errormessage = "At leaset one record is required for leads";            
               newValidator.evaluationfunction = function () {
                   var rowCount = 0;
                   rowCount = $("#Project_PartnerPortal").length;                
                   if (rowCount <=0) {
    				   alert("Yes it works for count 0");
                       return false;
                   } else {
    				   alert("Yes it works for count 1");
                       return true;
                   }
               };            
               Page_Validators.push(newValidator);
           });
        }(window.jQuery));
     }
     
     Also, I tried this code but the same was happened, 
    
     if (window.jQuery) {
       (function ($) {
           if (typeof (webFormClientValidate) != 'undefined') {
               var originalValidationFunction = webFormClientValidate;
               if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
                   webFormClientValidate = function () {
                       originalValidationFunction.apply(this, arguments);
                       // do your custom validation here
                       // return false;
                       // to prevent the form submit you need to return false
                       // end custom validation.                    
                       $("#new_fulladdress").prop('disabled', false);
                       $("#new_fulladdress_mailing").prop('disabled', false);
                       return true;
                   };
               }
           }
       }(window.jQuery));
    }

    Could you please help help me here! 

    Regards,

    Leo

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
Syed Aqib Raza Profile Picture

Syed Aqib Raza 42

#2
11manish Profile Picture

11manish 33 Super User 2026 Season 2

#2
Travis South Profile Picture

Travis South 33

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans