Route from Dialog using frappe.route_options

I can’t seem to get frappe.route_options to actually populate from my dialog.
Here’s the origin code:

primary_action: function(){
		var args = d.get_values();
		//console.log(args);
		if(!args) return;
		if(cur_frm.animal_status == 'Processed') {
			frappe.throw("This animal is already marked as processed")
		} else {
			new_process_animal = frappe.model.make_new_doc_and_get_name("Process Animal");
			frappe.route_options =
			{ "animal": cur_frm.doc.animal_identifier,
				"bom_repack": args.bom_repack,
				"animal_barcode": cur_frm.doc.animal_id_number,
				"hanging_weight": args.hanging_weight,
				"live_weight": args.live_weight,
				"process_date": args.process_date
			};
			//console.log(frappe.route_options);
			frappe.set_route("Form", "Process Animal", new_process_animal);
			}
		cur_frm.set_value('animal_status', 'Processed');
		cur_frm.save();
}

So from there it won’t populate the destination from fields, but it brings the object (correctly) with it.

What am I doing wrong?

I’m going answer my own question for posterity.

Well, you’re an idiot, that’s what. Just because you route some variables from one doctype to another doesn’t mean that the destination doctype knows what to do with them. If you want them to “populate the form” when they get there, then you have to tell it to populate the form:

cur_frm.set_value("docfield", variable);

That was really satisfying.

2 Likes