ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

[Tutorial] web forms tricks


web forms sometimes complex to work with especially when it’s changing and development added to it as it became better and better every version …
here is some of the things i learned after research you can find them here to follow :

1- for the listing page in portal here is how to add the headers of the list and the list content template html and the query to get them :

inside the controller you add this function like for exampe inside doctype task, i also created folder called template to add my template html inside it you can put it any where but is see it more organized this way :

def get_list_context(context):
context.get_list = get_encounter_list #  query return the data to be render in lest 
context.row_template = "yourcusutomapp/module/doctype/doctypename/templates/task_row_template.html"
context.result_heading_template = "yourcusutomapp/module/doctype/doctypename/templateresult_heading_template.html"

def get_encounter_list(doctype, txt, filters, limit_start, limit_page_length = 20, order_by='modified desc'):
#what every sql or orm query  you get data  as_dict = True

2- how to write your permission if the current user have what every … then he can see this else redirect

class DoctypeName(Document):

	def has_webform_permission(self):

     """ this function return true or false  :
       true he can see the docname in portal , false no """

i use this function in case of no

   frappe.local.flags.redirect_location = '/me'
    raise frappe.Redirect

3- if you want to create your own view for portal to show data for task for example
you create HTML field and only show it and hide all other fields …
put html field as Empty Div , and use client script on event after_load to append element to Dom
before save you update the frappe.web_form.values [ they are hidden but you you populate them and the frappe controller see them now ]
the same case if you want to show already entered data in webform … you check if it contains values then render them to HTML field …


if you have any useful information add it here so everybody can find them too


How to fillter link field based on other field value in this case area field linked to doctype City

frappe.web_form.on(‘area’, (field, value) => {

function filterCity(area) {
url: api/resource/City?filters=[["City","area","=","${area}"]],
success: function(result) {
var options = []
for (var i = 0; i <; i++) {

  var field = frappe.web_form.field_group.get_field('city');
  field._data = options;




For filter link field, here is a much easier way.

frm.set_query('city', function() {
    return {
        'filters': {
			'area': frm.doc.area,


this works on Desk , but not on web forms as far as i know have you test it ?


Sorry, I misunderstood I thought you meant on desk form. :sweat_smile: