Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1705 APIv4 - Support pseudoconstant lookups #17138

Merged
merged 2 commits into from
Apr 23, 2020

Conversation

colemanw
Copy link
Member

Overview

Access field option lists via APIv4, works for both inputs and outputs (note that for APIv3 it only works for inputs).
See discussion at https://lab.civicrm.org/dev/core/-/issues/1705

Before

APIv4 could only input/output a field's raw value.

After

Adding a suffix beginning with : to a field name tells the api to convert the raw value to/from an option name or label. Currently supported suffixes are :name, :label, and :abbr (abbr applies to a handful of fields like state_province).

Technical Details

Tests include converting names of states based on the name of a country, which goes off the chainSelect metadata to tell the api which variables to replace first so e.g. we know the country_id before attempting to lookup the list of states.

@civibot
Copy link

civibot bot commented Apr 22, 2020

(Standard links)

@civibot civibot bot added the master label Apr 22, 2020
@colemanw colemanw force-pushed the api4pseudoconstants branch 2 times, most recently from cbbf999 to ab97a69 Compare April 22, 2020 21:48
Appending a suffix to a field name e.g. location_type_id:name or gender_id:label
will automatically lookup values from field option lists.
@colemanw colemanw force-pushed the api4pseudoconstants branch from ab97a69 to d818aa7 Compare April 23, 2020 00:50
@eileenmcnaughton
Copy link
Contributor

I did some light testing - utilising these within a test & it seems good. Lots of tests on this & existing code gives us flexibility to make these changes

@eileenmcnaughton eileenmcnaughton merged commit e6590cf into civicrm:master Apr 23, 2020
@eileenmcnaughton eileenmcnaughton deleted the api4pseudoconstants branch April 23, 2020 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants