ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

AddReturnMessage

  • Summary
  • Discussion
  • Syntax
  • Code sample

Summary

Sets the return message of a script tool as an output message by index.

Discussion

There are times when you may want to return all messages from a tool you've called, regardless of message severity. Using the index parameter, AddReturnMessage will return a message from the last tool executed. The severity of the message (warning, error, and so on, is preserved).

Geoprocessing error numbers shown in the progress dialog box are hyperlinks to a help page that further describes the error. To enable hyperlinks for errors in your script, use the AddReturnMessage function instead of the AddError function, as follows:

import arcpy
try:    
    result = arcpy.GetCount_management("c:/data/rivers.shp")

except:    
    # Return Geoprocessing tool specific errors
    #
    for msg in range(0, arcpy.GetMessageCount()):
        if arcpy.GetSeverity(msg) == 2:
            arcpy.AddReturnMessage(msg)

Syntax

AddReturnMessage (index)
ParameterExplanationData Type
index

The message index.

Integer

Code sample

AddReturnMessage example

Returns all messages from the last tool executed as script tool output messages.

import arcpy

# Set current workspace
arcpy.env.workspace = "c:/data/base.gdb"

arcpy.Buffer_analysis("roads", "roads_buffer_1000", "1000 feet")

# Return the resulting messages as script tool output messages
for i in range(0, arcpy.GetMessageCount()):
    arcpy.AddReturnMessage(i)

Related topics

  • AddError
  • AddIDMessage
  • AddMessage
  • AddWarning
  • GetMessage
  • GetMessageCount
  • GetMessages
  • GetReturnCode
  • Writing messages in script tools
  • Understanding message types and severity
  • Understanding messages in script tools

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2019 Esri. | Privacy | Legal