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

Support AddToDefinition (add new field to feature service) #178

Open
JosiahParry opened this issue Mar 27, 2024 Discussed in #177 · 2 comments
Open

Support AddToDefinition (add new field to feature service) #178

JosiahParry opened this issue Mar 27, 2024 Discussed in #177 · 2 comments
Labels
enhancement New feature or request

Comments

@JosiahParry
Copy link
Collaborator

Discussed in #177

Originally posted by sarahhurley March 27, 2024
Hi there - I am wondering if there is the capability of adding a field to a feature layer through the arcgislayers package? I'm working on setting up a workflow that may require us to add a field to a dataset over time (trying to avoid needing to republish it every time). I've tried to look through the documentation, but I've only found in the "Overwrite Hosted Feature Layer" section of the R-ArcGIS Bridge documentation a line that says "Truncating a service does not change the field definitions or permit us to add or remove fields to it. If you wish to do so, publish a new layer instead."

Thanks for your help!

@JosiahParry
Copy link
Collaborator Author

For reference: #177 (comment)

@mmachir helped provide a sample POST request which should be easy to mimic in R

request url - 
https://services1.arcgis.com/unique-id-here/arcgis/rest/admin/services/heart_binary/FeatureServer/0/addToDefinition
 
method-
POST
 
payload - 
f: 
json
addToDefinition: 
{"fields":[{"name":"testfieldname","type":"esriFieldTypeString","alias":"Test Display Name","nullable":true,"editable":true,"length":256,"defaultValue":"~de fault-value!"}]}
token:  redacted

This should be fairly simple to mimic:

b_req <- arc_base_req(x[["url"]], path = "addToDefinition")
httr2::req_form_body(
    b_req,
    fields = fields_json
)

@JosiahParry JosiahParry added the enhancement New feature or request label Jul 8, 2024
@JosiahParry
Copy link
Collaborator Author

Note that this would allow us to also add related tables https://community.esri.com/t5/arcgis-online-questions/adding-related-table-to-arcgis-online-feature/td-p/252845

this could be a useful workflow when there are tables that have many matches to single polygons. Repeating the polygons is not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant