"description": "Adds a custom script (client or server) to a DocType",
"description": "Adds a custom script (client or server) to a DocType",
@@ -17,6 +18,7 @@
"fieldtype": "Link",
"fieldtype": "Link",
"hidden": 0,
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_list_view": 1,
"label": "DocType",
"label": "DocType",
@@ -27,6 +29,7 @@
"options": "DocType",
"options": "DocType",
"permlevel": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"read_only": 0,
"report_hide": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 0,
@@ -43,6 +46,7 @@
"fieldtype": "Select",
"fieldtype": "Select",
"hidden": 1,
"hidden": 1,
"ignore_user_permissions": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_list_view": 1,
"label": "Script Type",
"label": "Script Type",
@@ -53,6 +57,7 @@
"options": "Client",
"options": "Client",
"permlevel": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"read_only": 1,
"report_hide": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 0,
@@ -68,6 +73,7 @@
"fieldtype": "Code",
"fieldtype": "Code",
"hidden": 0,
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"in_list_view": 1,
"label": "Script",
"label": "Script",
@@ -78,6 +84,7 @@
"options": "Script",
"options": "Script",
"permlevel": 0,
"permlevel": 0,
"print_hide": 0,
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"read_only": 0,
"report_hide": 0,
"report_hide": 0,
"reqd": 0,
"reqd": 0,
@@ -93,14 +100,16 @@
"fieldtype": "HTML",
"fieldtype": "HTML",
"hidden": 0,
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"in_list_view": 0,
"label": "Sample",
"label": "Sample",
"length": 0,
"length": 0,
"no_copy": 0,
"no_copy": 0,
"options": "<h3>Custom Script Help</h3>\n<p>Custom Scripts are executed only on the client-side (i.e. in Forms). Here are some examples to get you started</p>\n<pre><code>\n\n// fetch local_tax_no on selection of customer\n// cur_frm.add_fetch(link_field, source_fieldname, target_fieldname);\ncur_frm.add_fetch(\"customer\", \"local_tax_no\", \"local_tax_no\");\n\n// additional validation on dates\nfrappe.ui.form.on(\"Task\", \"validate\", function(frm) {\n if (frm.doc.from_date < get_today()) {\n msgprint(\"You can not select past date in From Date\");\n validated = false;\n }\n});\n\n// make a field read-only after saving\nfrappe.ui.form.on(\"Task\", {\n refresh: function(frm) {\n // use the __islocal value of doc, to check if the doc is saved or not\n frm.set_df_property(\"myfield\", \"read_only\", frm.doc.__islocal ? 0 : 1);\n }\n});\n\n// additional permission check\nfrappe.ui.form.on(\"Task\", {\n validate: function(frm) {\n if(user==\"user1@example.com\" && frm.doc.purpose!=\"Material Receipt\") {\n msgprint(\"You are only allowed Material Receipt\");\n validated = false;\n }\n }\n});\n\n// calculate sales incentive\nfrappe.ui.form.on(\"Sales Invoice\", {\n validate: function(frm) {\n // calculate incentives for each person on the deal\n total_incentive = 0\n $.each(frm.doc.sales_team), function(i, d) {\n\n // calculate incentive\n var incentive_percent = 2;\n if(frm.doc.base_grand_total > 400) incentive_percent = 4;\n\n // actual incentive\n d.incentives = flt(frm.doc.base_grand_total) * incentive_percent / 100;\n total_incentive += flt(d.incentives)\n });\n\n frm.doc.total_incentive = total_incentive;\n }\n})\n\n</code>\n</pre>",
"options": "<h3>Custom Script Help</h3>\n<p>Custom Scripts are executed only on the client-side (i.e. in Forms). Here are some examples to get you started</p>\n<pre><code>\n\n// fetch local_tax_no on selection of customer\n// cur_frm.add_fetch(link_field, source_fieldname, target_fieldname);\ncur_frm.add_fetch(\"customer\", \"local_tax_no\", \"local_tax_no\");\n\n// additional validation on dates\nfrappe.ui.form.on(\"Task\", \"validate\", function(frm) {\n if (frm.doc.from_date < get_today()) {\n msgprint(\"You can not select past date in From Date\");\n validated = false;\n }\n});\n\n// make a field read-only after saving\nfrappe.ui.form.on(\"Task\", {\n refresh: function(frm) {\n // use the __islocal value of doc, to check if the doc is saved or not\n frm.set_df_property(\"myfield\", \"read_only\", frm.doc.__islocal ? 0 : 1);\n }\n});\n\n// additional permission check\nfrappe.ui.form.on(\"Task\", {\n validate: function(frm) {\n if(user==\"user1@example.com\" && frm.doc.purpose!=\"Material Receipt\") {\n msgprint(\"You are only allowed Material Receipt\");\n validated = false;\n }\n }\n});\n\n// calculate sales incentive\nfrappe.ui.form.on(\"Sales Invoice\", {\n validate: function(frm) {\n // calculate incentives for each person on the deal\n total_incentive = 0\n $.each(frm.doc.sales_team), function(i, d) {\n\n // calculate incentive\n var incentive_percent = 2;\n if(frm.doc.base_grand_total > 400) incentive_percent = 4;\n\n // actual incentive\n d.incentives = flt(frm.doc.base_grand_total) * incentive_percent / 100;\n total_incentive += flt(d.incentives)\n });\n\n frm.doc.total_incentive = total_incentive;\n }\n})\n\n</code>\n</pre>",