How to change the view of the form

I have created a new app but unable to change the view of the form.
Can someone explain me how to change or alter the existing view of the form.
Please explain with example if possible.


Not sure what you mean by changing the form view. GIve some example so that we can understand better.

Here I have added a new custom field total material cost in project and I want to get data from database as a method of project class in project DOC type get the all data in form according to particular project you open, i want value of total material cost field with it, so is there any inheritance concept as without inheritance you can not load the value of parent one with custom.

Write a whitelisted function. check this out

how to run sql query from custom script to fetch data from another doctype

You need to write the sql query in a server side python function and call it using the custom script

It is highly appreciated if you please provide one example for this.

in your .py

def some_method(some_arg):
x = frappe.db.sql(“YOUR_SQL_HERE”)
return x

in your .js

method: “”,
args: {
“some_arg”: arg
callback: function(r, rt) {
//do whatever you want here

1 Like