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 :
Microsoft Dynamics CRM (Archived)

Page Validator not working in Webform

(0) ShareShare
ReportReport
Posted on by 117

i m trying to put a page validator to check if there are records in the subgrid. If there is atleast one record in the subgrid it should progress to the next page otherwise it has to throw error. I have implemented a similar code ina different page and it is working fine. but for a different webform step this code isnt working. Can someone please tell me how we can debug a validator. My code is below


$(document).ready(function () {

if (typeof (Page_Validators) == 'undefined') return;
// Create new validator
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "SchoolPlacementvalidator";
newValidator.controltovalidate = "SchoolPlacement";
newValidator.errormessage = "<a href='#SchoolPlacement'>At least one Qualification item must be added to progress.</a>";
newValidator.evaluationfunction = function () {
var SchoolPlacement = $("#SchoolPlacement table tbody tr").length;
if (SchoolPlacement === 0) {
return false
}
else {
return true;
}

};
Page_Validators.push(newValidator);


});

*This post is locked for comments

I have the same question (0)
  • Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    I will suggest you to use chrome Developer tools and first check your code is working fine or not under the console

    $("#SchoolPlacement table tbody tr").length;

    it will help you to troubleshoot.

  • edev Profile Picture
    117 on at

    Hi Mahendar, thanks for responding back. I checked on the console already and it is working fine and giving me the right count.

  • Nicholas Hayduk Profile Picture
    2,863 on at

    Hi,

    When you say it doesn't work, does it give an error?  Or does it just let you proceed even if there are no rows in the table?

    As Mahender suggested, you'll probably need to use Developer Tools (F12) to get to the bottom of it.  I'd first put a breakpoint on the [if (SchoolPlacement === 0)] line of code, and make sure it is getting there when you click submit, and if it's giving you the value you'd expect.

    Nick

  • edev Profile Picture
    117 on at

    Hi Nicholas, it does not give any error and it proceeds to the next page. The problem with my code, we have put the code in app server and calling it in the respective steps and i m not able to debug the code inserting breakpoints. And also i tried to insert an alert and that doesnt work.

  • Nicholas Hayduk Profile Picture
    2,863 on at

    Sorry, I'm not quite following.

    The code you provided is JavaScript, which means it should run client-side (in the browser).  Where did you add the code to your Portal?  It should be added via the Custom JavaScript field on the Web Form Step.

    Once you have it in the right spot, you should be able to find it in your browser's Developer Tools, and then hopefully by putting a breakpoint there, the breakpoint will be hit when you click the submit button.

    Nick

  • edev Profile Picture
    117 on at

    Hi Nicholas, yes it is a javascript code and its a jquery call from client side to the script which resides in app server. I have resolved the issue by a temporary fix by disbaling the button until atleast one record is added to the subgrid.

  • Suggested answer
    Irena Benja Profile Picture
    414 on at

    Hi edev,

    Whenever there are no records on a list there is a message showing that can be the default one or some customized from your size.

    Maybe you can work with : contains("no data found"), so finding the presence of a text instead of the table rows.

    Something like this:

     $(".entity-grid.entitylist").on("loaded", function () {
     if($('span:contains("your txt")')){
    //your logic
     }
     });

    Hope it helps!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans