Let a controller method's output be accessible as a read_only field
See original GitHub issueIs your feature request related to a problem? Please describe. I have a Review doctype, which has an owner (the default document owner than frappe creates). I want to get the owner’s full name from the API, not the owner’s email address. Something like this:
/api/resource/Review?fields=["business", "remarks", "rating", "owner_full_name"]
.
Describe the solution you’d like
I can create a controller method (owner_full_name(self)
, maybe), whose output is the owner’s first name, plus their last name. I want to be able to provide this output as a read_only
field.
Describe alternatives you’ve considered
A linked field, for the user. The linked field could then be used with fetch_from
to get one attribute from the user. The problems with it are:
- it is not normal. It would simply duplicate data in the
owner
field. - it doesn’t let me get a second attribute from the linked field, or perform any computation on the linked field.
- Existing records would have to be updated, or they will return nothing.
I tried using dot notation as described here, but that didn’t work either.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I doubt it since it’s not a real database field. but you should be able to access it via
GET /api/resource/:doctype/:name
after #14593Can I access that
age
attribute through the API with something likeGET /api/resource/Person?fields=["age"]
?