[solved] How to add a row in a table using custom script?

Hi everyone,

Here is what I need to do:
when a record of my “action” doctype is submitted (and if the action_type is equal to " aty0001", I should display a prompt asking the user to add a new customer. Then when the user click on “add” a new record should be created in my “customer” table.

Below is the custom script I have coded for the moment.

My problem is that I don’t know how to add a record (a row) in the “customer” table form the custom script. Can anybody put me on the right way?

cur_frm.cscript.custom_before_submit = function(doc) {
       	if (doc.action_type === 'aty0001') {
    			{'default': get_today(),'fieldname': 'interest_date', 'fieldtype': 'Date', 'label': 'Interest date', 'reqd': 1},
    			{'fieldname': 'customer_gender', 'fieldtype': 'Select', 'label': 'Gender', 'options': 'Mr.\nMrs.', 'reqd': 1},
    			{'fieldname': 'name', 'fieldtype': 'Data', 'label': 'Customer name', 'reqd': 1},
    			{'fieldname': 'customer_type','fieldtype': 'Select','label': 'Customer type','options': 'Regular\nInfluencer\nPromoter\nVillage Chief'},
    			{"fieldname": "cb01","fieldtype": "Column Break"},
    			{'fieldname': 'phone_one','fieldtype': 'Data','label': 'Phone 1','reqd': 1},
    			{'fieldname': 'phone_two','fieldtype': 'Data','label': 'Phone 2'},
    			{'fieldname': 'village','fieldtype': 'Link','in_list_view': 0,'label': 'Village','options': 'village','reqd': 1}
    			var cg = data.customer_gender;
    			var n = data.name;
    			msgprint("Added customer: " + cg + " "+ n + ".");
    			$('#tabcustomer tr:last').after('<tr>data.customer_gender</tr><tr>data.name</tr><tr>data.phone_one</tr><tr>data.phone_two</tr><tr>data.village</tr>');
    		'Please add a new interested customer',
            validated = true;


I used a server side script in py and the frappe.get_doc({ … }).insert(ignore_permissions = True) method. Works perfectly.