Created
April 6, 2016 06:43
-
-
Save RobertSchouten/673cf231e24912b418f8e9079dd0481e to your computer and use it in GitHub Desktop.
on save create child and then pass back to doctype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (frm.doc.__islocal != 1) { | |
var route = frappe.get_prev_route() | |
if (route[1] == "User") { | |
var found = false | |
var userdoc = frappe.get_doc("User",route[2]); | |
for (i = 0;i<userdoc.user_emails.length;i++){ | |
if (userdoc.user_emails[i].email_account==cur_frm.doc.name){ | |
found = true | |
} | |
} | |
if (!found) { | |
var new_row = frappe.model.add_child(userdoc, "User Emails", "user_emails"); | |
new_row.email_account = cur_frm.doc.name; | |
new_row.awaiting_password = cur_frm.doc.awaiting_password; | |
new_row.email_id = cur_frm.doc.email_id; | |
frappe.route_options = "unsaved" | |
frappe.set_route(route) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment