List of Functions (wip)

I’m going to try to compile a list of useful functions here. If anyone has any, please reply and I will add them to this top post. Hopefully this will make it easier for people to find the function they need.

Fetching Data
//Fetches a field from one document to another.  
//Link-field in your target document, that points to your source document.
//Source - Field you are pulling from
//Target - Field you are putting the pulled information.
cur_frm.add_fetch('link','source','target');
Time
//Gets today's date
frappe.datetime.get_today()

//Calculates the difference between two dates
frappe.datetime.get_day_diff("2016-05-05", "2016-05-03" )

//Adds the specified number of days
frappe.datetime.add_days("2016-05-03", 2)
2 Likes

Check this wiki page

Haven’t used them, so I can’t verify whether they need updates (post was last updated in 2014). Server side calls look to be incorrect. Client side looks to be OK.

some of those will still work, but that is the old way of making them. I’m pretty sure that anything that refers to ‘wn’ will not work.

There is actually a Developer Cheat Sheet you can update it!

Note : cur_frm is no longer the standard for writing JS code. Refer to this

2 Likes

@vjFaLk The Developer Cheat Sheet does reference cur_frm under the globals section though. Is this obsolete, or is there particular uses for cur_frm?

You can still use it in the JS Console to get information for debugging purposes (eg cur_frm.doc.[field_name]) but if you’re writing JS code, you should refrain from that.

@vjFaLk what would be the replacement for cur_frm.add_fetch then? I’ve been trying various things, but haven’t gotten anything to work except that.