I have an inventory system setup for our Sign Department and it generates a list of what's in stock every night which I would like to use as CVD for our maintenance reports on our sign layer. Since this list changes daily I need a way to update my feature service with the updated data. Any help or examples would be very appreciated.
Thanks!
So the domain values would change every night? Are the people out there looking at the reports making changes to those domain fields?
If they are not why even use domains at all.
If a Sign in inventory has a qty of 0 it is pulled from the available signs shown in the drop down list for our maintenance reports so that the drop down doesn't become massive. Once they complete maintenance the sign they chose from the drop down is subtracted from the current inventory table using another python script.
So you domain is the name of the sign?
Why not just a definition query on the inventory level to not show those with a quantity of 0?
If the worker changes the inventory level to 0 it is removed from the list when they save
Maybe you can try the following code to update the domain values of a service
Try it on a test service before updating your production service.
item <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'ItemID'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#get the FeatureLayerCollection</SPAN> flc <SPAN class="operator token">=</SPAN> FeatureLayerCollection<SPAN class="punctuation token">.</SPAN>fromitem<SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#define the update dictionary</SPAN> update_dict <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"fields"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"fieldx"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"domain"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"codedValue"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Signs"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"codedValues"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Option A"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"code"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"type_a"</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Option B"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"code"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"type_b"</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="string token">"name"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"Option C"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"code"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"type_c"</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="comment token">#update the featureservice definition</SPAN> flc<SPAN class="punctuation token">.</SPAN>manager<SPAN class="punctuation token">.</SPAN>update_definition<SPAN class="punctuation token">(</SPAN>update_dict<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Please let us know if it works.
I get a message:
{'success': True}
but when I look at the layer interface (the list of values) or review the json of the service (.../rest/admin/services/..), nothing has changed. When I do this manually (on the rest/admin/services update definition I have to change the line lasteditdate = " " (removing the date and replacing with quotes with a space following the known issues described in:https://support.esri.com/en/technical-article/000014622) and then the changes are successfully applied.
Wouldn't you also need to include this lasteditdate line in your dictionary?
If so, I've tried something like this (see below) with the same 'success' message but without changes successfully applied.
#define the update dictionary ##test using the entire copy of the json of the service ##(as if you were doing it manual update with the .../rest/admin/services/... url for that service) update_dict = { "editingInfo" : { "lastEditDate" : " " }, "fields": [ { "name": "OccurTaxoID", "domain": { "type": "codedValue", "name": "cvd_OccurTaxoID", "codedValues": [ { "name": "Amphibian!!: Unknown/Other", "code": "-1113" }, { "name": "Frog/Toad!!: Unknown/Other", "code": "-1114" }, { "name": "Frog/Toad!!: Bullfrog", "code": "-1115" } ] } } ] }
Any movement on updating domains for a feature service (or in my case a hosted table)? I have noticed that while using the overwrite function to keep my layers up to date, it overrides the domain lists created in AGOL.
Here's a workflow from the always helpful @jcarlson https://community.esri.com/t5/arcgis-enterprise-blog/update-a-hosted-field-domain-with-the-python-api/ba-p/1182716
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.