question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Let a controller method's output be accessible as a read_only field

See original GitHub issue

Is 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:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gavindsouzacommented, Oct 28, 2021

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 #14593

0reactions
daraulcommented, Oct 27, 2021

Can I access that age attribute through the API with something like GET /api/resource/Person?fields=["age"]?

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to set select element as readonly ('disabled' doesnt pass ...
see this answer - HTML form readonly SELECT tag/input. You should keep the select element disabled but also add another hidden input with...
Read more >
readonly keyword - C# Reference - Microsoft Learn
A readonly field can be assigned and reassigned multiple times within the field declaration and constructor.
Read more >
HTML attribute: readonly - HTML: HyperText Markup Language
The Boolean readonly attribute, when present, makes the element not mutable, meaning the user can not edit the control.
Read more >
Declare and Initialize Read-only Auto Properties in C# ...
In this guide, we will take the concepts of fields and properties and see how both can be read-only and how they are...
Read more >
Forms in HTML documents - W3C
Form submission method; Successful controls; Processing form data ... text input: Authors may create two types of controls that allow users to input...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found