...
jsonb_extract_path_text (values.jsonb,'id') as AS value_id, ----- note that in this case, the "id" we're getting is a text element, not a UUID
jsonb_extract_path_text (values.jsonb,'value') as AS value_name
------ because "values" is a jsonb object (produced by the cross join below), we need to use json extract statements in "Select" to get the value id and the value name from "values"
...
- Final note: if you want to include "ordinality" as part of your results – this is the order in which the extracted values appear in the source record – you would insert "WITH ordinality" before the "AS values (jsonb)":
CROSS JOIN LATERAL LATERAL jsonb_array_elements (jsonb_extract_path (cf.jsonb, 'selectField', 'options', 'values')) WITH ordinality AS values (jsonb)
Then you would add a line in the Select stanza to show the ordinality:
values.ordinality AS custom_fields_ordinality
...