Child table get blank on save

Hello team,

I’m having some issues with a couple of custom scripts that always worked fine on v12. First:

frappe.ui.form.on("Delivery Note",{
    srv_inhumacion: function(frm) {
		frm.trigger("carta_ubicacion");
	},
	validate: function(frm) {
		frm.trigger("carta_ubicacion");
	},
    carta_ubicacion: function(frm){
        frm.clear_table('carta_ubicacion_referencia');
        frappe.call({
            method:"frappe.client.get_list",
            args:{
                doctype:"Sales Invoice Item",
                fields:["item_code", "item_name", "servicio", "description", "qty", "uom", "warehouse", "batch_no", "serial_no"],
                parent: "Sales Invoice",
                filters: [
                    ["parent", "=", frm.doc.sales_invoice]
                    ],
            },
            callback: function (r) {
                console.log(r.message);
                if (r.message) {
                    $.each(r.message, function(index, row) {
                        var d = frm.add_child("carta_ubicacion_referencia");
                        d.item_code = row.item_code;
                        d.item_name = row.item_name;
                        d.servicio = row.servicio;
                        d.description = row.description;
                        d.qty = row.qty;
                        d.uom = row.uom;
                        d.warehouse = row.warehouse;
                        d.batch_no = row.batch_no;
                        d.serial_no = row.serial_no;
                        d.item_code = row.item_code;
                    });
                }
                frm.refresh_field("carta_ubicacion_referencia");
            }
		});
	}
});

And also used to work using this second script:

frappe.ui.form.on("Delivery Note", {
	srv_inhumacion: function(frm) {
		frm.trigger("carta_ubicacion");
	},
	carta_ubicacion: function(frm) {
        if(frm.doc.srv_inhumacion && frm.doc.sales_invoice){
            frm.clear_table("carta_ubicacion_referencia");
            frappe.model.with_doc("Sales Invoice", frm.doc.sales_invoice, function () {
                var tabletransfer = frappe.model.get_doc("Sales Invoice", frm.doc.sales_invoice);
                frm.set_value('si_naming_series', tabletransfer.si_naming_series);
                $.each(tabletransfer.items, function (index, row) {
                    var d = frm.add_child("carta_ubicacion_referencia");
                    d.item_code = row.item_code;
                    d.item_name = row.item_name;
                    d.servicio = row.servicio;
                    d.description = row.description;
                    d.qty = row.qty;
                    d.uom = row.uom;
                    d.warehouse = row.warehouse;
                    d.batch_no = row.batch_no;
                    d.serial_no = row.serial_no;
                    frm.refresh_field("carta_ubicacion_referencia");
                    frm.refresh();
                });
            });
        }
        else {
            frm.set_value("sales_invoice", "");
            frm.set_value("funeraria", "");
            frm.set_value("use_stock", "");
            frm.clear_table("carta_ubicacion_referencia");
        }
    },
});

Both worked fine on v12. But you’ll see that now apparently the table seems to get blank on save and I’m mean apparently because I if clic on print, data appears on print format. I have to refresh to see again the data on the table.

This error appears on console when first clic on srv_inhumacion to load data on table

Uncaught TypeError: Cannot read property 'startsWith' of null
        at HTMLAnchorElement.<anonymous> (router.js:54)
        at HTMLBodyElement.dispatch (jquery.min.js:3)
        at HTMLBodyElement.r.handle (jquery.min.js:3)

When clic on save, these two appears on console

Unable to handle success response 
1.docinfo: {attachments: Array(0), attachment_logs: Array(0), communications: Array(0), automated_messages: Array(0), comments: Array(0), …}
2.docs: [{…}]
3.[[Prototype]]: Object
TypeError: Cannot read property 'toLowerCase' of undefined
        at Object.slug (router.js:418)
        at frappe.meta.docfield_map.<computed>.<computed>.formatter (form.js:1510)
        at Object.frappe.format (formatters.js:326)
        at grid_row.js:263
        at Array.forEach (<anonymous>)
        at GridRow.setup_columns (grid_row.js:257)
        at GridRow.render_row (grid_row.js:212)
        at GridRow.make (grid_row.js:38)
        at new GridRow (grid_row.js:16)
        at Grid.render_result_rows (grid.js:360)

Any hint to solve would be much appreciated!

The last two errors:
Unable to handle success response and TypeError: Cannot read property 'toLowerCase' of undefined, send to line

catch(e) {
				console.log("Unable to handle success response", data); // eslint-disable-line
				console.trace(e); // eslint-disable-line
			}

on this

frappe.request.call = function(opts) {
	frappe.request.prepare(opts);

	var statusCode = {
		200: function(data, xhr) {
			opts.success_callback && opts.success_callback(data, xhr.responseText);
		},
		401: function(xhr) {
			if(frappe.app.session_expired_dialog && frappe.app.session_expired_dialog.display) {
				frappe.app.redirect_to_login();
			} else {
				frappe.app.handle_session_expired();
			}
		},
		404: function(xhr) {
			if (frappe.flags.setting_original_route) {
				// original route is wrong, redirect to login
				frappe.app.redirect_to_login();
			} else {
				frappe.msgprint({title: __("Not found"), indicator: 'red',
					message: __('The resource you are looking for is not available')});
			}
		},
		403: function(xhr) {
			if (frappe.session.user === "Guest" && frappe.session.logged_in_user !== "Guest") {
				// session expired
				frappe.app.handle_session_expired();
			} else if (xhr.responseJSON && xhr.responseJSON._error_message) {
				frappe.msgprint({
					title: __("Not permitted"), indicator: 'red',
					message: xhr.responseJSON._error_message
				});

				xhr.responseJSON._server_messages = null;
			} else if (xhr.responseJSON && xhr.responseJSON._server_messages) {
				var _server_messages = JSON.parse(xhr.responseJSON._server_messages);

				// avoid double messages
				if (_server_messages.indexOf(__("Not permitted")) !== -1) {
					return;
				}
			} else {
				frappe.msgprint({
					title: __("Not permitted"), indicator: 'red',
					message: __('You do not have enough permissions to access this resource. Please contact your manager to get access.')});
			}


		},
		508: function(xhr) {
			frappe.utils.play_sound("error");
			frappe.msgprint({title:__('Please try again'), indicator:'red',
				message:__("Another transaction is blocking this one. Please try again in a few seconds.")});
		},
		413: function(data, xhr) {
			frappe.msgprint({indicator:'red', title:__('File too big'), message:__("File size exceeded the maximum allowed size of {0} MB",
				[(frappe.boot.max_file_size || 5242880) / 1048576])});
		},
		417: function(xhr) {
			var r = xhr.responseJSON;
			if (!r) {
				try {
					r = JSON.parse(xhr.responseText);
				} catch (e) {
					r = xhr.responseText;
				}
			}

			opts.error_callback && opts.error_callback(r);
		},
		501: function(data, xhr) {
			if(typeof data === "string") data = JSON.parse(data);
			opts.error_callback && opts.error_callback(data, xhr.responseText);
		},
		500: function(xhr) {
			frappe.utils.play_sound("error");
			try {
				opts.error_callback && opts.error_callback();
				frappe.request.report_error(xhr, opts);
			} catch (e) {
				frappe.request.report_error(xhr, opts);
			}
		},
		504: function(xhr) {
			frappe.msgprint(__("Request Timed Out"))
			opts.error_callback && opts.error_callback();
		},
		502: function(xhr) {
			frappe.msgprint(__("Internal Server Error"));
		}
	};

	var ajax_args = {
		url: opts.url || frappe.request.url,
		data: opts.args,
		type: opts.type,
		dataType: opts.dataType || 'json',
		async: opts.async,
		headers: Object.assign({
			"X-Frappe-CSRF-Token": frappe.csrf_token,
			"Accept": "application/json",
 			"X-Frappe-CMD": (opts.args && opts.args.cmd  || '') || ''
		}, opts.headers),
		cache: false
	};

	if (opts.args && opts.args.doctype) {
		ajax_args.headers["X-Frappe-Doctype"] = encodeURIComponent(opts.args.doctype);
	}

	frappe.last_request = ajax_args.data;

	return $.ajax(ajax_args)
		.done(function(data, textStatus, xhr) {
			try {
				if(typeof data === "string") data = JSON.parse(data);

				// sync attached docs
				if(data.docs || data.docinfo) {
					frappe.model.sync(data);
				}

				// sync translated messages
				if(data.__messages) {
					$.extend(frappe._messages, data.__messages);
				}

				// callbacks
				var status_code_handler = statusCode[xhr.statusCode().status];
				if (status_code_handler) {
					status_code_handler(data, xhr);
				}
			} catch(e) {
				console.log("Unable to handle success response", data); // eslint-disable-line
				console.trace(e); // eslint-disable-line
			}

		})
		.always(function(data, textStatus, xhr) {
			try {
				if(typeof data==="string") {
					data = JSON.parse(data);
				}
				if(data.responseText) {
					var xhr = data;
					data = JSON.parse(data.responseText);
				}
			} catch(e) {
				data = null;
				// pass
			}
			frappe.request.cleanup(opts, data);
			if(opts.always) {
				opts.always(data);
			}
		})
		.fail(function(xhr, textStatus) {
			try {
				var status_code_handler = statusCode[xhr.statusCode().status];
				if (status_code_handler) {
					status_code_handler(xhr);
				} else {
					// if not handled by error handler!
					opts.error_callback && opts.error_callback(xhr);
				}
			} catch(e) {
				console.log("Unable to handle failed response"); // eslint-disable-line
				console.trace(e); // eslint-disable-line
			}
		});
}

Any thoughts?

Did you get any solution yet?
I am facing the same issue in v13 also.

No, not any at all.