Link field in doctype to a virtual doctype throws KeyError


I am getting data from external api and mapping it to virtual doctype. Now linking that virtual doctype to another doctype field to create a lookup throws keyerror.

By looking the server found that error occurs in frappe/frappe/desk/

def relevance_sorter(key, query, as_dict):

value = _( if as_dict else key[0])
return (cstr(value).lower().startswith(query.lower()) is not True, value)

The key here, in my case, shows dictionary and as_dict as False. Generally, the key has tuple data. So what can I do solve this error or is there any other way to implement this?

Solution :
- Use as_list from args of method get_list() in your Virtual DocType class.

Example :

Problem :

  • For Link field suggestion list of list require but due to Virtual Doctype’s json list of dict is returned.
1 Like