Try ERPNext Buy Support Partners Foundation

Get data from form field for a custom script

I want to access data from a field in the doctype (Address) once the page is loaded, perhaps with a button calling the function in the custom script. The function should just fetch the data from the current form, assign it to another javascript variable, do some calculations, and then the variable with the result needs to be assigned to an HTML element by ID.
Simple, but I can’t seem to access the cusotm field names.

Help!

@Tropicalrambler

frappe.model.get_value('DocType', 'name', 'fieldname') // 1st way
cur_frm.doc.fieldname // 2nd way
3 Likes

@Tropicalrambler
please refer this link

Thanks

2 Likes

Max, thank you, I was fiddling with the different ways of doing this, and the one that worked:
// 2nd way

Now on to parsing my data :smile:

I also realized that I was having problems with function scopes.

Sagar, thanks, i find that method a bit complex, yet I believe one day I shall need it and it will sink in and I will keep it in mind.

1 Like