I am finding it quite hard to write custom scripts which work well. I understand the documentation is still in its beta stage. But it would be a great deed if someone would write some more documentation/scripts on client side and server side scripts explaining how to fetch values within the same form, between forms, how to interact with tables,links , assigning values etc. This could help beginners like me to learn quickly and a lot of queries in the forum will be answered automatically.
The above link helps a bit, but its hard to figure out whats happening since its just examples.
Hoping this would be done soon.
Hey ,
Thank you for showing interest. i am sure this post will help a lot of them like me.
How do we copy value from one field to another field in the same form? (generally)
How do we copy value of one field of form A into another field of form B ?
3.How to access values of fields within a table of a form ?
4.What are the different ways of setting values for a field ? what other properties of a field can be modified using code ?
These are some of the questions in my mind right now, which i didnât find any direct solution. Feel free to use own assumptions for type of field, etc. Just a general example which can be used to replicate in various situations will do.
Also either client or server script will do, whichever you feel is the best practice.
Thank you for your time and efforts
Regards,
Akarsh
Lets see, we have one requirement.
In Purchase Invoice, We need to add Payment Due Date. Payment Due Date is equal to Posting Date + Credit Days.
Also one more requirement, Supplier Invoice No should be unique in all Purchase Invoice.
Steps to achieve this. 1) Create custom field âCredit Daysâ and âDue Dateâ in Purchase Invoice.
To fetch value of Credit Days from supplier into purchase invoice, write this script in Purchase Invoice.
def validate_bill_no(self, method):
if self.bill_no:
# validate bill no is unique
bill_list = frappe.db.sql("""select name from `tabPurchase Invoice` where bill_no=%s and docstatus =1""",
self.bill_no)
if len(bill_list) > 0:
items = [e[0] for e in bill_list if e[0]!=self.name]
frappe.throw(_("Supplier Invoice Number must be unique. Current Supplier Invoice Number already exists for {0}").format(comma_and(items)))
if self.bill_date:
if getdate(self.bill_date) > getdate(self.posting_date):
frappe.throw(_("Supplier Invoice Date cannot be after Purchase Order Date"))
This will help you to write client and server side script. Please ask if you have any doubt in this example.
Hey,
That was useful. It might take some time for me to sink it in. Meanwhile, Cant we modify the value of a field which is âread onlyâ ?
I have a form which has employee link field which a read only field called âdef_shiftâ.
When i select the employee, i want the âshift_defâ field of that employee to be copied to âdef_shiftâ in this new form. I have used this code. But it doesnât seem to work.