@frappe.whitelist()
def validate_link():
 import frappe
 import frappe.utils
 (value, options, fetch) = (frappe.form_dict.get(u'value'), frappe.form_dict.get(u'options'), frappe.form_dict.get(u'fetch'))
 if ((not options) or (options == u'null') or (options == u'undefined')):
  frappe.response[u'message'] = u'Ok'
  return
 valid_value = frappe.db.sql((u'select name from `tab%s` where name=%s' % (frappe.db.escape(options), u'%s')), (value,))
 if valid_value:
  valid_value = valid_value[0][0]
  if fetch:
   fetch = u', '.join((u'`{0}`'.format(frappe.db.escape(f.strip())) for f in fetch.split(u',')))
   frappe.response[u'fetch_values'] = [frappe.utils.parse_val(c) for c in frappe.db.sql((u'select %s from `tab%s` where name=%s' % (fetch, frappe.db.escape(options), u'%s')), (value,))[0]]
  frappe.response[u'valid_value'] = valid_value
  frappe.response[u'message'] = u'Ok'

@ frappe . whitelist ( ) def validate_link ( ) : import frappe import frappe . utils ( value , options , fetch ) = ( frappe . form_dict . get ( u'value' ) , frappe . form_dict . get ( u'options' ) , frappe . form_dict . get ( u'fetch' ) ) if ( ( not options ) or ( options == u'null' ) or ( options == u'undefined' ) ) : frappe . response [ u'message' ] = u'Ok' return valid_value = frappe . db . sql ( ( u'select name from `tab%s` where name=%s' % ( frappe . db . escape ( options ) , u'%s' ) ) , ( value , ) ) if valid_value : valid_value = valid_value [ 0 ] [ 0 ] if fetch : fetch = u', ' . join ( ( u'`{0}`' . format ( frappe . db . escape ( f . strip ( ) ) ) for f in fetch . split ( u',' ) ) ) frappe . response [ u'fetch_values' ] = [ frappe . utils . parse_val ( c ) for c in frappe . db . sql ( ( u'select %s from `tab%s` where name=%s' % ( fetch , frappe . db . escape ( options ) , u'%s' ) ) , ( value , ) ) [ 0 ] ] frappe . response [ u'valid_value' ] = valid_value frappe . response [ u'message' ] = u'Ok'
validate link when updated by user .