Child Table Customization - Auto Create Row

i’ve created child table,
i want when i add first row it should pick today date, and when i put hours it should create 2nd row and 2nd date should 1 day after today date mean today date is 29 mar then 2nd row date should be 30 mar.
and this loop should run whenever i put hours. the next row should open with tomorrow date.

like below:

Any body??

@rmehta @joelios @vishdha @komsel2228 ??? any body please ???

You get this I hope Child Table Row Increment - #3 by umair

How about identify what you have done so far to implement this?

Yes i’ve got this.
Thanks for your reply @clarkej

I’ve created above attached pictures Child table,
i’ve want when i fill hours in row then second row with next date should automatically open,
Else when i create new form 15 rows of child table should be already created.
is there any possibilities of my above 2 scenarios?

Yes and what do you offer here?


Share your code implementation - you have none?

No i don’t have. i am newbie, thats why i am asking. :frowning:

Right so like most of us here you are passionate and have some learning to do.

Also note that all here volunteer their help, so to hound them is a turn off!

edit: yes please contribute Want to calculate check-in time & check-out time - #7 by rmehta

Sir, i’ve & i am contributing, i 've also helped few peoples as my knowledge,
lets get back on my this topic,
I also want to learn, but my bad luck i don’t have any idea that how to play with child table,
i’ve learned many things from this forum, i can play with client side script, but have no idea how to play with child table, as i want auto row increment, can you please help me sir?

How does your childtable called? And how does the doctype called in which you add the childtable?

Thanks for you reply @joelios :slight_smile:
Doctype name is “Time Tracking” & Child table name is “Time Tracking Table”.

Ok, and how is the fieldname (type = table) in doctype Time Tracking?

And am I right, that the “Date” Field in the childtable is called date and the “Hours” hours?

fieldname of datatype of table is “time_tracking_table”

In child table.
Yes exactly Date is named as date & Hours is named as hours

Try this in custom script of doctype “Time Tracking” (its not tested…)

frappe.ui.form.on('Time Tracking Table', {
	time_tracking_table_add: function(frm) {
		var row = cur_frm.doc.items.length - 1;
		if (row == 0) {
			var today = new Date();
			var dd = today.getDate();
			var mm = today.getMonth()+1;
			var yyyy = today.getFullYear();
			today = yyyy + '-' + mm + '-' + dd;
			frappe.model.set_value(cur_frm.doc.items[row].doctype, cur_frm.doc.items[row].name, "date", today);
		} else {
			var tomorrow = new Date();
			tomorrow.setDate(tomorrow.getDate() + row);
			frappe.model.set_value(cur_frm.doc.items[row].doctype, cur_frm.doc.items[row].name, "date", tomorrow);
	hours: function(frm) {
		frappe.model.add_child(cur_frm.doc, "Time Tracking Table", "time_tracking_table");
1 Like

Thank you so much @joelios for your help,
it is working when i save the document. i want to run this script on when i put hours,
second thing, date is not picking up automatically in new row, i want second row with next date as selected on above row. for example first row is dated as 10/4/2018 second date in second row should be 11/4/2018.