Child table validation

How we can add validation on field of child table ?

Could you elaborate on what exactly you mean and what your use case is?

Suppose I am on sales order page and add new field ‘length’ in items (child table). We need to add validation on ‘length’ field. Length fetch from item doctype and match with sales order item field ‘length’.

Child DocType field validation is similar to DocType field validation.

frappe.ui.form.on('Sales Order Item', {
  'length': function(frm) {
    // your validation logic here

Hello @vaibhavk,

You’ll need to add a custom script for this one in Sales Order. If the trigger is the change in the length field, then the following script might work:

frappe.ui.form.on("Sales Order Item", "length", function(frm, cdt, cdn){
    var so_item = locals[cdt][cdn];{
       callback: function(data){
               if(message.length == so_item.length)
                   msgprint("Replace this with what you want to do if item length == sales order item length");

@netchampfaris @littlehera How we can trigger a keyup event because above code working only the first time?

The code triggers after you’ve changed the “length” field, @vaibhavk. So if you click outside the items table and then edit the length value again, it should work.

But if you really need to detect the keystroke, you’ll need to create either a js function or jquery code to detect the keyup event.

@littlehera I have already done with jquery but we need frappe code for this.

When we click on action button, then (‘Sales order Item’) form will open in pop-up. If we change the value of length column, then trigger a keyup event . It will work only first time