Hi all, I’m having issues with a custom button. Here is the basic thing I need to happen;
I have one form (where the button is). This form is used to fill out information and then the user clicks a button and the code is supposed to take certain values from the actual page and pre-fill a samples form with that information.
Here is my code:
make_sample(frm){
var Sample = frappe.model.get_new_doc("Sample");
frappe.route_options = {
"model":cur_frm.doc.model_name,
"season":cur_frm.doc.season,
}
frappe.set_route('Form', 'Sample', Sample.name);
This is what’s happening:
- User fills out form. Clicks button. [Correct!]
- User is then navigated to Sample Form. [Correct!]
- Data is not preloaded. [Not Correct]
But, if the user navigates back (with the browser) and clicks on button again, the following happens:
- User is navigated to Sample Form [Correct!]
- Data IS PREloaded [Correct!]
So basically this code should be correct, but I am not able to load the data for the new document on a first attempt. Is this a glitch, or am I missing something?