How to use frappe.utils methods in server script

How to use frappe.utils methods in server script

Here Server Script are instructions for server script

I tried to write for example frappe.utils.nowdate() and ,but I get error

Is there any another syntax to write a frappe.utils methods

Thanks in advance

share what you have done so far

Try this
frappe.datetime.now_datetime() , frappe.datetime.get_today()

frappe.utils.nowdate() should work. Can you please share the error?

TypeError: ‘NoneType’ object is not callable

submitted_on is a custom field.

Hello @alkuhlani,

I am facing this same problem, have you found any solution?

Vishakha Mishra

1 Like

No :cry:

1 Like

I think now it is working.

I can’t use frappe.utils.xlsxutils.read_xlsx_file_from_attached_file()

@indrawow Due to security issues, only selected methods are available in the server script.

To anyone looking to manipulate dates from within a Server Script, the following is an example of how to jump momentarily from the safe, impossible-to-do-any-harm zone of the Python sandbox into the safe, impossible-to-do-any-harm zone of your entire corporate database:

def getThisMonthRange():
    data = frappe.db.sql("""
                SELECT LAST_DAY(now()) AS last_day
              , DATE(date_add(now(),interval -DAY(now())+1 DAY)) AS first_day;
    return data[0]

date_dict = getThisMonthRange()
firstOfMonth = date_dict.first_day
endOfMonth = date_dict.last_day