CreateWebLayerSDDraft doesn't include Date Field configuration?

937
5
Jump to solution
07-05-2019 10:57 AM
SeanLawrence
New Contributor II

So I'm having an issue where I'm trying to automate publishing a feature service to AGO using python where it's failing at the analyze during StageService_server ([{"code":"00129","message":"Map has layers that record Editor Tracking dates in database time zone, but time zone has not been defined","object":"Map"}]).

               
The layers successfully publish using ArcGIS Pro 2.4 when setting the Date Field configuration to the appropriate time zone (as I'm using database time).

I'm assuming there is no Date Field configuration with CreateWebLayerSDDraft as it's not in the documentation.  Am I missing something?  Is there a work around that anyone knows about?

I'm messing around with the sddraft configuration and setting

<PropertySetProperty xsi:type='typens:PropertySetProperty'><Key>hasEditorTrackingDatesInDbTimezone</Key><Value xsi:type='xs:string'>true</Value></PropertySetProperty>

Doesn't seem to help

1 Solution

Accepted Solutions
ScottMoore__Olympia_
Esri Contributor

I would look at dateFieldsTimeReference for use with the publish_parameters option.  It would look something like this in code:

from arcgis.gis import GIS
sd_itemid = "a71a0a30cd0e4cde9d196f99e935a919"
gis = GIS("https://www.arcgis.com", "YourAGOLUserName")

#Find SD file, then update or add, then publish
sd_item = gis.content.get(sd_itemid)

#Parameters for editor tracking
pub_params = {"dateFieldsTimeReference" : {"timeZone":"Pacific Standard Time"}}

sd_item.publish(publish_parameters=pub_params, overwrite=True)

More of the doc can be found here:

https://developers.arcgis.com/rest/users-groups-and-items/publish-item.htm

View solution in original post

5 Replies
ScottMoore__Olympia_
Esri Contributor

I would look at dateFieldsTimeReference for use with the publish_parameters option.  It would look something like this in code:

from arcgis.gis import GIS
sd_itemid = "a71a0a30cd0e4cde9d196f99e935a919"
gis = GIS("https://www.arcgis.com", "YourAGOLUserName")

#Find SD file, then update or add, then publish
sd_item = gis.content.get(sd_itemid)

#Parameters for editor tracking
pub_params = {"dateFieldsTimeReference" : {"timeZone":"Pacific Standard Time"}}

sd_item.publish(publish_parameters=pub_params, overwrite=True)

More of the doc can be found here:

https://developers.arcgis.com/rest/users-groups-and-items/publish-item.htm

NataliyaLys
Occasional Contributor II

Scott Moore (Olympia)‌ thank you for posting this. I was able to add it to my script, and update the time zone.

ScottMoore__Olympia_
Esri Contributor

Sean Lawrence‌ Does this answer this question?

0 Kudos
SaraKidd
Occasional Contributor

Will this work for a file GDB? I added this parameter and got the error:

"User cant overwrite this service, using this data, as this data is already referring to another service.
(Error Code: 500)"

This GDB is only being used in one service.

0 Kudos
ScottMoore__Olympia_
Esri Contributor

I only tested with a service definition file, not a file geodatabase.  It does look like it should work from a file geodatabase based on the API ref:

arcgis.gis module — arcgis 1.8.2 documentation 

From the error, it appears that the feature service has already been published from the file geodatabase.  You could delete the feature service (keep the file geodatabase item) and try it (make sure you have backed up the feature service if there have been changes to it that you want to keep).  The sd_itemid would point to an item of type "File Geodatabase" that hasn't yet had a feature service published from it.

0 Kudos