Output information about Attendance in Course Schedule List

I need output information about Attendance in Course Schedule List.
I need to see, note Instructor attendance for Course Schedule or no?
Please, watch screenshot for more understanding.

How to do it? I need to create some Server Script?
Can you help me in that?

Or maybe I need just Field in Customization?
So how to create field?

@goldenscrew . open customization → customize form and enter your doctype . then add as more fields as you need .
for the data itself , you need to write a script that does the checking and changes the field if necessary

Can you give me more instructions?

I did like this

@goldenscrew. Add ,(dont edit ) a new row in the Course schedule customization . the type better be (select) , the name is your choice. check “in list view”. button the options can be (Yes,No), one in each line. Default must be (No). also check the “read only” button.
this is the first part . do it and come back to me

I did it.

@goldenscrew did it appear in the list view where you wanted it ?

YEs!! But with null!

@goldenscrew you havn’t set default to No . anyways for the script I recomand a server script .
create a new server script. set a name , the reference is Student Attendance. event (after submit ). script try teh bellow:

cs = frappe.get_doc("Course Schedule",doc.course_schedule)
if cs.attendance !="Yes":

next . add any new student attendance , when you submit it . open the list and check if attendance in that course schedule changed to Yes .


Thank you very much!!! It works!

@goldenscrew, you’re welcome . now when you understood how it works , you can change the select type to int or even data . and instead of yes and no you can write numbers or anything else .
here are some script documentations that may help you:
Document api
Database API

yes! Thanks!!!

Good day @bahaou

Please allow me to compliment you the way you have helped @goldenscrew. This is what an open-source community is all about.

(1) He did stuff himself…
(2) you helped him with some stuff
(3) you gave him the tools so he can take it further

I don’t know what @goldenscrew has in terms of experience, but if I can just reflect on my own
frustration when it comes to customization within ERPNext. I have written lots of
C-code which is a different style of coding. So it requires one to change the way you
approach ERPNext-code. So it makes the first few steps one takes to write your own code in
ERPNext a bit more challenging. Its almost like one needs to get over an initial hill first to overcome that mindset that one is used to

I really think that the DEVs have done a good job when they developed the use-cases but
there are places that one wants to modify … like in this case.

I have also seen things that I want changed and I am also battling. And if those of us that
are not so comfortable about writting code is assisted in the way you have just now, then
later on we can also assist others.

Thank you


Sorry. Can you write another example…?
I need to receive amount of student in group, that attached to the Course Schedule.

I try to use next code:

cs = frappe.get_doc("Course Schedule",doc.course_schedule)
cs.count_of_marks = cs.get_list.student_group.students

@goldenscrew hello again .
to get number of student who attended the course schedule use :

frappe.db.count("Student Attendance",{"course_schedule":name_here,"status":"Present"})

where and when exactly you want this number to be stored ?

1 Like
cs = frappe.get_doc("Course Schedule",doc.course_schedule)
# cs.count_of_marks = frappe.get_list(cs.student_group.students)
cs.count_of_marks = frappe.db.count("Student Attendance",{"course_schedule":cs.name,"status":"Present"})

Thanks! I did it and it works.
Now I try understand, how to do it faster.
Because now, I try to test and it takes much time.

How can I see result before do DocType Event?

Also, I want to see all arguments or attributes…
How to use PHPStorm for it? Because this way with adding Server Script is very low and hard.
Hope for understanding.

@goldenscrew open the terminal in the bench repository and write (bench console), here you can write all server script and you will get the results instantly .

notice that I wrote the name of course schedule manually.
all the methods in the 2 docs I mentioned before will work here),you can also edit docs with doc.save() but they will not be committed unless you commit them using frappe.db.commit()
also , the console is a python ide, so you can also write python code like for loops and stuff.

to see a all doctypes fields , there are many ways .
easiest way : open doctype list → set doctype → fields are in the table (use names not Labels)

1 Like

Thank you!!

how can i get the count of students are linked with the student group