Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· openaiHugging Face Suzhen/CodeChat

i want create client script on frappe to edit date when sales invoice refresh but if…

  1. User

    i want create client script on frappe to edit date when sales invoice refresh but if it's new

  2. Assistant

    To create a client script on Frappe that edits the date when a Sales Invoice is refreshing for a new record, you can follow these steps:

    1. Go to the "Custom Scripts" doctype in Frappe.
    2. Click on "New" to create a new client script.
    3. Set the "DocType" field to "Sales Invoice".
    4. Set the "Script Type" field to "Client".
    5. In the "Script" field, enter the following code:
    frappe.ui.form.on('Sales Invoice', {
        refresh: function(frm) {
            if (frm.doc.__islocal) { // Check if it is a new record
                var newDate = frappe.datetime.now_date(); // Set new date
                frm.set_value('posting_date', newDate); // Update posting_date field
            }
        }
    });
    
    1. Save the script.

    Now, whenever a Sales Invoice is refreshed, if it's a new record, the script will automatically update the posting_date field with the current date.

    Note: Make sure you have the necessary permissions to create and manage custom scripts in your Frappe instance.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.