This.wrapper.find return error

// Copyright (c) 2015, Frappe Technologies and contributors
// For license information, please see license.txt

cur_frm.add_fetch(“course”, “course_code”, “course_code”);
cur_frm.add_fetch(‘fee_structure’, ‘total_amount’, ‘amount’);

frappe.ui.form.on(“Program”, “refresh”, function(frm) {
if(!frm.doc.islocal) {
(“Student Applicant”), function() {
frappe.route_options = {
frappe.set_route(“List”, “Student Applicant”);

	frm.add_custom_button(__("Program Enrollment"), function() {
		frappe.route_options = {
		frappe.set_route("List", "Program Enrollment");
	frm.add_custom_button(__("Student Group"), function() {
		frappe.route_options = {
		frappe.set_route("List", "Student Group");
	frm.add_custom_button(__("Fee Structure"), function() {
		frappe.route_options = {
		frappe.set_route("List", "Fee Structure");
	frm.add_custom_button(__("Fees"), function() {
		frappe.route_options = {
		frappe.set_route("List", "Fees");


this.wrapper.find(“.primary-action”).click(function() {

i want to get print hi in cosole but i get error

Uncaught TypeError: Cannot read property ‘find’ of undefined(…)


In form you can set the primary action button click event using set_primary_action.

e.g., function() {

but it will override the primary button action and you will need to write code for form save, Can you please share the usecase ?


1 Like

thanks for the replay

my use case is i have a button in website

when i click on that button i want to show in console

or to generate a pdf file

html file is

{% extends “templates/web.html” %}

{% block content %}

<div class="row">
	<div class="">
		<h1>Details of the Program {{ }}</h1>
	<div class="col-md-3">
		{% if doc.image -%}
			<img itemprop="brand" src="{{ doc.image }}" class="program-logo col-md-12"
				alt="{{ doc.program_name }}" title="{{ doc.program_name }}" />
		{%- endif %}
	<div class="col-md-9">
	    <section class="col-md-12" id="pgm">
			<label>Name of programs:</label><h2 id="pgmName">{{ doc.program_name }}</h2>
			<label>Programm abbrevation</label><p id="pgmAbbr">{{ doc.program_abbreviation }}</p>
			<label>programme code</label><p id="pgmCode">{{ doc.program_code }}</p>
			<label>Programme department <p id="pgmDepartment">{{ doc.department  }}</p>	
			<p>Courses Offered in this program : </p>  {% for c in courses %} <p id ="pgmCourse">{{ c.course }} </p>{% endfor %}
			<p>Total Fees For This Program: </p>  {% for c in fees %} <p id="pgmAmount">{{ c.amount }} </p>{% endfor %}
		<button class="btn-download-pdf btn-primary pull-left" id="download" data-field="program">Download Pdf</button>

{% endblock %}

For webview set_primary_action will not work you will need to write the javascript in script tag in html file itself.

Please check the for example.

@makarand_b Thanks again it solved my half problem


can you please help me with creating pdf


can i get the doctype form this script

like this


now i get

Cannot read property ‘doc’ of undefined


it will only work on Form view as you are working on webview this.frm.doc will not work



i want to execute this code in the script

var w =
+“&no_letterhead=”+(me.with_letterhead() ? “0” : “1”)
+(me.lang_code ? (“&_lang=”+me.lang_code) : “”)));
if(!w) {
msgprint(__(“Please enable pop-ups”)); return;

is there any way to do that