% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/form_schema_ext.R
\name{form_schema_ext}
\alias{form_schema_ext}
\title{Show the extended schema of one form.}
\usage{
form_schema_ext(
  flatten = FALSE,
  odata = FALSE,
  parse = TRUE,
  pid = get_default_pid(),
  fid = get_default_fid(),
  url = get_default_url(),
  un = get_default_un(),
  pw = get_default_pw(),
  odkc_version = get_default_odkc_version(),
  retries = get_retries(),
  verbose = get_ru_verbose()
)
}
\arguments{
\item{flatten}{Whether to flatten the resulting list of lists (\code{TRUE})
or not (\code{FALSE}, default). Only applies to ODK Central version < 0.8.}

\item{odata}{Whether to sanitise the field names to match the way they will
be outputted for OData. While the original field names as given in the
XForms definition may be used as-is for CSV output, OData has some
restrictions related to the domain-qualified identifier syntax it uses.
Only applies to ODK Central version < 0.8.
Default: \code{FALSE}.}

\item{parse}{Whether to parse the form schema into a tibble of form field
type and name. This uses \code{\link{form_schema_parse}} internally.
If used together with \code{flatten=TRUE}, \code{\link{form_schema}} will raise
a warning and return the unparsed, flattened form schema.
Only applies to ODK Central version < 0.8.
Default: TRUE.}

\item{pid}{The numeric ID of the project, e.g.: 2.

Default: \code{\link{get_default_pid}}.

Set default \code{pid} through \code{ru_setup(pid="...")}.

See \code{vignette("Setup", package = "ruODK")}.}

\item{fid}{The alphanumeric form ID, e.g. "build_Spotlighting-0-8_1559885147".

Default: \code{\link{get_default_fid}}.

Set default \code{fid} through \code{ru_setup(fid="...")}.

See \code{vignette("Setup", package = "ruODK")}.}

\item{url}{The ODK Central base URL without trailing slash.

Default: \code{\link{get_default_url}}.

Set default \code{url} through \code{ru_setup(url="...")}.

See \code{vignette("Setup", package = "ruODK")}.}

\item{un}{The ODK Central username (an email address).
Default: \code{\link{get_default_un}}.
Set default \code{un} through \code{ru_setup(un="...")}.
See \code{vignette("Setup", package = "ruODK")}.}

\item{pw}{The ODK Central password.
Default: \code{\link{get_default_pw}}.
Set default \code{pw} through \code{ru_setup(pw="...")}.
See \code{vignette("Setup", package = "ruODK")}.}

\item{odkc_version}{The ODK Central version as a semantic version string
(year.minor.patch), e.g. "2023.5.1". The version is shown on ODK Central's
version page \verb{/version.txt}. Discard the "v".
\code{ruODK} uses this parameter to adjust for breaking changes in ODK Central.

Default: \code{\link{get_default_odkc_version}} or "2023.5.1" if unset.

Set default \code{get_default_odkc_version} through
\code{ru_setup(odkc_version="2023.5.1")}.

See \code{vignette("Setup", package = "ruODK")}.}

\item{retries}{The number of attempts to retrieve a web resource.

This parameter is given to \code{\link[httr]{RETRY}(times = retries)}.

Default: 3.}

\item{verbose}{Whether to display debug messages or not.

Read \code{vignette("setup", package = "ruODK")} to learn how \code{ruODK}'s
verbosity can be set globally or per function.}
}
\value{
A tibble containing the form definition.
For ODK Central 0.8, and with default parameters
(\code{parse=TRUE}) for ODK Central 0.7, \code{\link{form_schema}} returns
a tibble with the columns:

\itemize{
\item \code{name} The field name as given in the form schema.
\item \code{type} The field type, e.g. "string", "select1", etc.
\item \code{path} The XForms path of the field,
\item \code{ruodk_name} The predicted field name as generated by
\code{\link{odata_submission_get}}, prefixed by the path, additionally
cleaned with \code{\link[janitor]{make_clean_names}} to match the
cleaned column names from \code{\link{odata_submission_rectangle}}.
\item \code{label} The field label as given in the form schema.
If specific languages are available,
this column will return the \code{default} language or it will be empty
if this is not specified.
\item \code{label_lang} The field label in languange \emph{_lang} as
given in the form schema.
\item \code{choices} A list of lists containing at least \code{values} and,
if available, \code{labels} of the choices as given in the form schema.
If specific languages are available, this column will return the
\code{default} language or it will be empty if this is not specified.
Please notice that whenever choice filters are applied, this will return
the unfiltered choice list.
\item \code{choices_lang} A list of lists containing at least
\code{values} and, if available, \code{labels} of the choices in language
\emph{_lang} as given in the form schema.
Please notice that whenever choice filters are applied, this will return
the unfiltered choice list.

}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
}
\details{
ODK Central has introduced a new API endpoint in version 0.8 which
returns a parsed and flattened list of fields. This replaces the nested
form schema which is challenging to parse. This list is returned
by \code{\link{form_schema}}.

However this still misses important elements, in particular \code{labels} and
\code{choice_lists}.

\code{\link{form_schema_ext}} returns the same object as
\code{\link{form_schema}}
adding \code{labels} and \code{choice lists} in all languages available.
This is done by using the return object from \code{\link{form_xml}}.

It has the exact function signature as \code{\link{form_schema}}.
In that sense, any call to \code{\link{form_schema}} can be replaced
by \code{\link{form_schema_ext}}

This function, however, has been prepared with ODK Central version 0.8 or
higher. If you use it with an earlier version, a warning will be given.
}
\examples{
\dontrun{
# See vignette("setup") for setup and authentication options
# ruODK::ru_setup(svc = "....svc", un = "me@email.com", pw = "...")

# With current ODK Central (>0.7)
# get extended schema:
fsx <- form_schema_ext()

# print choice list in english:
fsx[fsx$name == "test_yn", "choices_english_(en)"][[1]]

# view the extended schema:
fsx
}
}
\seealso{
\url{https://docs.getodk.org/central-api-form-management/#getting-form-schema-fields}

\url{https://docs.getodk.org/central-api-form-management/#retrieving-form-xml}

Other form-management: 
\code{\link{form_detail}()},
\code{\link{form_list}()},
\code{\link{form_schema}()},
\code{\link{form_xml}()}
}
\concept{form-management}
