How to fetch a column from a table and compare its values with a string to validate

Hi I am trying to do a validation task and for that i am tryin to fetch a column from a table and comparing its values with a string. If the value in a column matches with the string it gets validated but i dont know how to fetch the column

Hi @Ujjawal,

can you share your code / script ?

The thing is i am new to erpnext and python so i need your guidance regarding how to fetch
I dont know the function to fetch data from table
and so havent written the code yet

You need to be bit clear on what you need with example. And you should atleast start something so that we can help.

@Ujjawal,

to fetch data from python script you can use the frappe.db.get_value , frappe.db.get_values or frappe.db.sql methods

I am working on HR Module and want to customize it.
The thing is i have created a table named Job Interview and linked the table with job applicant Doctype. in table Job Interview theres a field named applicant_status the string what i want to compare with the values in column applicant_status is “Cleared” i.e. if the applicant have cleared interview we can make offer letter to that job applicant.
So plz provide me with your valuable feedback.

@Ujjawal,

please refer following code

def validate(self):
	status = list(set([row.applicant_status for row in self.child_table_fieldname]))
	if status and status[0] == "Cleared":
		# issue offer letter to applicant

you can something similar in order to compare the value.

Thanks, Makarand

@Ujjawal,

Please refer to developer tutorials for doc_events and triggers,

You can also find the video tutorials for frappe framework on YouTube

Thanks, Makarand

Thank You so Much For your Help.