Try ERPNext Buy Support Partners Foundation

Conditional Default Value

Hi Folks

Following is my use case

i am creating a custom doc type and i have a column date in my doc type and i want to default this date by incremental hours and or days based on certain condition , both side of conditions

for e.g. If A=B th then date must be previous date+2 hours
and if C=D then date must be previous date+2 days

Can anyone suggest , how can i achieve this with examples if any ?

Rgds
O

When do you want the date updated? When the doctype is created or everytime something changed on the doctype?

For client-side you can refer to this link for the datetime utils that you can use:

you need somethings like this:

var current_datetime = frappe.datetime.now_datetime();
if(C=D){
var added_datetime = frappe.datetime.add_days(current_date,2)
}

for adding hours you’ll probably have to read the momentjs documentations