<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I test if there was a rollback? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-can-i-test-if-there-was-a-rollback/m-p/1057458#M6054</link>
    <description>&lt;P&gt;After some try and error I got this response:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{'addResults': [{'objectId': 1, 'uniqueId': 1, 'globalId': None, 'success': False, 'error': {'code': 1003, 'description': 'Operation rolled back.'}}, {'objectId': None, 'uniqueId': None, 'globalId': None, 'success': False, 'error': {'code': 1000, 'description': 'String or binary data would be truncated.\r\nThe statement has been terminated.'}}], 'updateResults': [], 'deleteResults': []}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of the Google result for "1003 Operation rolled back." is:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/error-handling-with-sync-operations.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/error-handling-with-sync-operations.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Seems like the REST API returns 1003 for rollbacks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on above response, I could do something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def is_rolled_back(result):

    for element in result["addResults"]:
        if "error" in element and element["error"]["code"] == 1003:
            return False
    return True

# example with adding records
result = layer.edit_features(add=records, rollback_on_failure=True)

if is_rolled_back(result):
    # do something&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this is everything else than a satisfying solution. &lt;U&gt;It's solely based on assumptions due to non-existing documentation.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I don't know if the error code 1003 would always be the first element. As I said, all based on assumptions. If it is always the first element, above code can be simplified!&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Other ideas and inputs are very welcome and appreciated!&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 May 2021 02:05:31 GMT</pubDate>
    <dc:creator>Thomas_Z1</dc:creator>
    <dc:date>2021-05-13T02:05:31Z</dc:date>
    <item>
      <title>How can I test if there was a rollback?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-can-i-test-if-there-was-a-rollback/m-p/1057433#M6051</link>
      <description>&lt;P&gt;How can I test if there was a rollback?&lt;/P&gt;&lt;P&gt;Where do I find the documentation for Feature Layer's edit_feature method's response?&lt;/P&gt;&lt;P&gt;It's not documented here:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.FeatureLayer.edit_features" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.FeatureLayer.edit_features&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;result = layer.edit_features(updates=records, rollback_on_failure=True)

# looking for something like
if result["rollback"]:
    # do something&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, the API documentation is incomplete. The official documentation only specifies: "Output: dictionary".&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 02:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-can-i-test-if-there-was-a-rollback/m-p/1057433#M6051</guid>
      <dc:creator>Thomas_Z1</dc:creator>
      <dc:date>2021-05-13T02:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can I test if there was a rollback?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-can-i-test-if-there-was-a-rollback/m-p/1057458#M6054</link>
      <description>&lt;P&gt;After some try and error I got this response:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{'addResults': [{'objectId': 1, 'uniqueId': 1, 'globalId': None, 'success': False, 'error': {'code': 1003, 'description': 'Operation rolled back.'}}, {'objectId': None, 'uniqueId': None, 'globalId': None, 'success': False, 'error': {'code': 1000, 'description': 'String or binary data would be truncated.\r\nThe statement has been terminated.'}}], 'updateResults': [], 'deleteResults': []}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of the Google result for "1003 Operation rolled back." is:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/rest/services-reference/enterprise/error-handling-with-sync-operations.htm" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/rest/services-reference/enterprise/error-handling-with-sync-operations.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Seems like the REST API returns 1003 for rollbacks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on above response, I could do something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def is_rolled_back(result):

    for element in result["addResults"]:
        if "error" in element and element["error"]["code"] == 1003:
            return False
    return True

# example with adding records
result = layer.edit_features(add=records, rollback_on_failure=True)

if is_rolled_back(result):
    # do something&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this is everything else than a satisfying solution. &lt;U&gt;It's solely based on assumptions due to non-existing documentation.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I don't know if the error code 1003 would always be the first element. As I said, all based on assumptions. If it is always the first element, above code can be simplified!&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Other ideas and inputs are very welcome and appreciated!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 May 2021 02:05:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-can-i-test-if-there-was-a-rollback/m-p/1057458#M6054</guid>
      <dc:creator>Thomas_Z1</dc:creator>
      <dc:date>2021-05-13T02:05:31Z</dc:date>
    </item>
  </channel>
</rss>

