Add select field type to the child table

i want add custom script to create select field include “Item Group,Category”
when i select any one must retrieve data and appearing it another select field type

is here any help?

Means, you want 2 select fields.

In one field there is only 2 options:

  1. Item Group
  2. Category

And in second, data of that first field.

Right?

  1. Add the First Select Field** in the child table (Sales Incentives Criteria Tab) with options like “Item Group” and “Category”.
  2. Add the Second Select Field in the same child table, which will dynamically show options based on the first field’s selection.
  3. Write the script to dynamically populate the second field based on the value chosen in the first field.

If Item Group and Category is doctype then you can make first field Link field and set query to get only these 2 doctypes. And second field should be Dynamic Link field and in its options pass first field’s fieldname.

hi

i only want to know how can i make select field in a child table and fill it in the data not manually but by using scrip report this is first one

Use customiz form to create custom field.

Custom Field.

Then use client script or server script according to your requirements.

https://frappeframework.com/docs/user/en/desk/scripting/client-script

frappe.ui.form.on('Sales Incentives Criteria', {
    onload: function(frm) {
        frm.fields_dict['sales_incentives_criteria_tab'].grid.get_field('select_field').get_query = function(doc, cdt, cdn) {
            return {
                filters: {}
            };
        };
    }
});

frappe.ui.form.on('Sales Incentives Criteria Tab', {
    select_field: function(frm, cdt, cdn) {
        let row = locals[cdt][cdn];

        if (row.select_field) {
            let doctype_to_fetch;

            if (row.select_field === 'Item Group') {
                doctype_to_fetch = 'Item Group';
            } else if (row.select_field === 'Item') {
                doctype_to_fetch = 'Item';
            } else if (row.select_field === 'Category') {
                let category_options = ['Category 1', 'Category 2', 'Category 3'];
                frappe.model.set_value(cdt, cdn, 'dynamic_options', category_options.join('\n'));
                frm.refresh_field('sales_incentives_criteria_tab');
                return;
            }

            if (doctype_to_fetch) {
                frappe.call({
                    method: 'frappe.client.get_list',
                    args: {
                        doctype: doctype_to_fetch,
                        fields: ['name'],
                        limit_page_length: 1000
                    },
                    callback: function(r) {
                        if (r.message) {
                            let options = r.message.map(d => d.name).join('\n');
                            frappe.model.set_value(cdt, cdn, 'dynamic_options', options);
                            frm.refresh_field('sales_incentives_criteria_tab');
                        }
                    }
                });
            }
        }
    }
});

i want show data in dynamic_options as (select type) , now the data one line .
can i get help

> frappe.ui.form.on('Your Parent Doctype', {
>     // Trigger when the select field changes
>     category_type: function(frm) {
>         if (frm.doc.category_type) {
>             // Call the server-side method to get data
>             frappe.call({
>                 method: 'your_app.your_module.get_category_items',
>                 args: {
>                     category_type: frm.doc.category_type
>                 },
>                 callback: function(r) {
>                     if (r.message) {
>                         // Update options for child table select field
>                         frm.fields_dict['child_table_field_name'].grid.update_docfield_property(
>                             'item_selector',
>                             'options',
>                             r.message.join("\n")
>                         );
>                     }
>                 }
>             });
>         }
>     }
> });

I’m using UI how can i make this Idea?