Compartilhar via


GetLoggedExceptionDataByKey

Description

Retrieves a single exception object from the log based on the logId value supplied.

Parameters

Parameter

Type

Description

logId

guid

A key that uniquely identifies the logged exception.

context

Context

Specifies information about how the method will be called.

Return Value:

Value

Type

Description

GetLoggedExceptionDataByKeyResult

LoggedExceptionData

A LoggedExceptionData object.

Interfaces

  • Dynamics GP
  • Common
  • Field Service
  • Financials
  • Human Resources/Payroll
  • Inventory
  • Manufacturing
  • Project Accounting
  • Purchasing
  • Sales

Examples

The following C# example retrieves a logged exception. The error message from the exception is displayed in a message box. To use this example, the logid GUID in the example should be replaced with a valid logid from the exception log.

Cc508493.LegacyEndpoint(en-us,MSDN.10).gif** Legacy endpoint**

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            Guid guid;
            LoggedExceptionData loggedSystemException;

            // Create an instance of the service
            DynamicsGP wsDynamicsGP = new DynamicsGP();

            // Be sure that default credentials are being used
            wsDynamicsGP.UseDefaultCredentials = true;

            // Create a context object with which to call the service
            context = new Context();

            // Specify which company to use (sample company)
            companyKey = new CompanyKey();
            companyKey.Id = (-1);

            // Set up the context object
            context.OrganizationKey = (OrganizationKey)companyKey;

            // Create a Guid with the id value of the logged exception to retrieve
            guid = new Guid("511db25b-962d-4d10-ba3f-b929a82ae434");

            // Retrieve the exception
            loggedSystemException = wsDynamicsGP.GetLoggedExceptionDataByKey(guid, context);

            // Display the exception message from the ExceptionDetail property
            MessageBox.Show("Error message: " + loggedSystemException.ExceptionDetail.Message);
        }
    }
}

Cc508493.NativeEndpoint(en-us,MSDN.10).gif** Native endpoint **

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
    class Program
    {
        static void Main(string[] args)
        {
            CompanyKey companyKey;
            Context context;
            Guid guid;
            LoggedExceptionData loggedSystemException;

            // Create an instance of the service
            DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();

            // Create a context object with which to call the service
            context = new Context();

            // Specify which company to use (sample company)
            companyKey = new CompanyKey();
            companyKey.Id = (-1);

            // Set up the context object
            context.OrganizationKey = (OrganizationKey)companyKey;

            // Create a Guid with the id value of the logged exception to retrieve
            guid = new Guid("511db25b-962d-4d10-ba3f-b929a82ae434");

            // Retrieve the exception
            loggedSystemException = wsDynamicsGP.GetLoggedExceptionDataByKey(guid, context);

            // Display the exception message from the ExceptionDetail property
            MessageBox.Show("Error message: " + loggedSystemException.ExceptionDetail.Message);

            // Close the service
            if(wsDynamicsGP.State != CommunicationState.Faulted)
            {
                wsDynamicsGP.Close();
            }
        }
    }
}