Data Population from other DocType

Hi,

I am just going through the Library Management tutorial. I have completed Article, Library Member and trying to complete Library Membership. DocType for the same as follows:

However, after selecting Library Member, there First Name and Last Name is not populating automatically. Someone, please advice.

BR/Mijan

Have you tried it with edit in full page?
and it that confirm that Doctype Library Member have both fields named first_name and last_name?
And have filled?

1 Like

yes, full page and quick both were tried, both field names are correct and have data.

BR/Mijan

Then it should work, try to clear your chache using ctrl + shift + r

Tried, but no luck. Is it necessary to write any script for the same?

BR/Mijan

Not required any script to do that, i am wondering that why it not working, you are probably be doing some mistake, anyways try this script to achieve that.

frappe.ui.form.on("Libray Memebership", "library_member", function(frm) {
    frappe.call({
        "method": "frappe.client.get",
        "args": {
             "doctype": "Library Member",
             "name": frm.doc.library_member
        },
        "callback": function(response) {
             var library_member = response.message;
             if (library_member) {
                  frm.set_value('member_first_name', library_member.first_name);
                  frm.set_value('member_last_name', library_member.last_name);
             } else {
                  frappe.msgprint("Member not found");
            }
        }
    }); 
});

For curiosity, I just downloaded and implement library_management app from github.
That is also behaving same.

@umair @rmehta can any one help me?

BR/Mijan

Hello @shahid,

Script works fine. But, are you sure this should work without JS?

BR/Mijan

Are you using the develop version of Frappe?

i.e., in your screenshot

where you wrote library_member.first_name, click on the inverted triangle beside it to open all the options for the field. Below the options field are you able to see a Fetch From labelled field?

If so, add library_member.first_name in this field and remove it from options field. Do the same for library_member.last_name. Save the DocType and reload the page.

Now try to create a new membership and see if the first and last name are getting fetched or not.

1 Like

Yes, also try the suggestion of Zlash.

@Zlash65 @shahid Yes, this works fine.

Thank you very much.

BR/Mijan