Select to view content in your preferred language

Update domain values in hosted feature layer without overwrite

715
1
07-27-2023 11:41 AM
Labels (2)
Tiff
by
Occasional Contributor III

Is there a good method in updating domains directly in a hosted feature service? This includes adding new values and ensuring that they are sorted alphabetically. I would like to be able to pull in a csv with the code and description as separate columns and directly update the domain list, without overwriting. Updating domains directly in the AGOL item content data tab is not ideal due to having to add and sort them manually, which can lead to error or potentially excluding some values.

Like Survey123 allows you to reference external choice lists for dropdown options and update them dynamically using linked csvs, I would like to be able to have that same functionality and same domain within the layer so that it can be used in other apps such as Field Maps and web apps.

Any suggestions or best practices appreciated!

0 Kudos
1 Reply
RhettZufelt
MVP Notable Contributor

I use this script for that purpose all the time. ( I don't use the provider credential part, just hardcode the user/password in the script)

I have my table in Excel and sort the way I want.

Then I use this formula to 'JSONify' it:

="{" & """name"""&" : "&"""" & A2 & """" & ", " &"""code""" & "  :  " & """" & B2 & """" & "},"

 

Delete the last comma, copy/paste (values) into the update_dict portion of the script, and run it.

I normally run from a Notebook in Pro.

Will replace the Domain list with the new one, sorted the same way as the input table.

If I need to make changes in the future, just open the notebook, make the changes in the upadte_dict, and re-run.

R_

 

0 Kudos