Tampilkan postingan dengan label Integration Manager. Tampilkan semua postingan
Tampilkan postingan dengan label Integration Manager. Tampilkan semua postingan

Selasa, 26 Agustus 2014

Customizating Integration Manager Logs - Part 2

Customizating Integration Manager Logs - Part 2

In my previous post I talked about all the out of the box options for setting up Integration Manager ("IM") logs and frankly, the Trace level log is good for most users of IM users. However, when "good" is not good enough, it's necessary to resort to some of the objects and functions available as part of IM's scripting library.

Errors Collection object, Error object, and functions

Integration Manager provides the Errors Collection object which is nothing more than a collection or list of all the errors generated during an integration. The Errors Collection must be explicitly retrieved in order to work with the properties within the collection. To navigate the collection we need the Error object to get information about the specific error within the Errors Collection, for example, time of the error, the specific error text, and the type of severity (error or warning).

IM also provides a number of functions that allow a developer to write into the log file directly. These functions are: LogDetail, LogDocDetail, LogWarning, and LogDocWarning. Each of these functions is discussed in greater detail in Part 5 - Using VBScript, Chapter 22 - Functions of the Integration Manager User's Guide. The following example puts all these together:

After Document script
'
' Created by Mariano Gomez, MVP
' This code is licensed under the Creative Commons
' Attribution-NonCommercial-ShareAlike 3.0 Generic license.
Const SEVERITY_MEDIUM 1000
Const SEVERITY_CRITICAL 2000

Dim imErrors ' reference the Errors Collection
Dim imError ' reference a specific error within the collection

Set imErrors = GetVariable("Errors") 
If imErrors.Count > 0 Then
 For i = 1 to imErrors.Count
  Set imError = imErrors.Item(i) ' get the error represented by the index
 
  'Check the severity level of the error
  if imError.Severity = GetVariable("SeverityWarning") then
   'We have hit a warning
   LogDocWarning imError.MessageText, "", SEVERITY_MEDIUM, "Customer Name", SourceFields(somequery.CustomerName)
  Else
  ' We hit a major issue, so now we really want to log all details details
   LogDocDetail imError.MessageText, "", SEVERITY_CRITICAL, "Customer Name", SourceFields(somequery.CustomerName)
  End If
 Next 'Continue if there's more than 1 error
End If
 

Note that you can add event logs from anywhere where scripting is allowed in IM. The above sample code is just a small example of how you could customize the logs further, with information that's meaningful to you and your users.

Hope you found this information useful.

Until next post!

MG.-
Mariano Gomez, MVP
Intelligent Partnerships, LLC
http://www.IntelligentPartnerships.com

Senin, 25 Agustus 2014

Customizing Integration Manager Logs - Part 1

Just recently, I took on a question on the Microsoft Dynamics GP Partner Online Technical Forum where the original poster asked if it was possible to customize the logs produced by Integration Manager ("IM").

Before we get into the customization aspects of the log, let's start by remembering that IM already offers 4 levels of log customization out of the box: a Summary log, a Document level log, a Trace level log and, if you consider no log an option, then None. In the case of a Document level log, information about every integrated record is logged, including the document number (keep in mind that document here refers to the entire envelope of data regardless of whether it's an actual document or a master record). The Trace level log, in addition to the Document level information, examines and outputs all the steps performed by IM to get the document into Microsoft Dynamics GP, including any errors or warnings that Microsoft Dynamics GP may send back to IM.

IM Properties window - Logs tab

At this point, the above options are out of the box and do exactly what Microsoft developers intended. However, what if you really want to extend the capabilities of the log to provide some additional information that is not currently covered by the Document or Trace level logs? It is possible to provide this extra piece of information if you are familiar with IM event scripts.

IM Properties window - Scripts tab
In particular, the Document Warning, Document Error, and Integration Error event scripts allow you to make use of the VBScript scripting editor to extend the information you may include in the log file, regardless of log trace level. As the events suggest, the Document Warning event will fire when IM receives a warning from Microsoft Dynamics GP in response to an attempt to integrate a document, i.e., a missing distribution account when integrating a journal entry. While the journal will still integrate, it means that further editing work will be required in Microsoft Dynamics GP to add the missing account and balance the journal transaction before posting is possible.

In contrast, the Document Error event fires when Microsoft Dynamics GP cannot accept the master record or transaction being imported due to inconsistencies with the data. For example, a SOP invoice is submitted with missing required field, causing the document to be rejected by Microsoft Dynamics GP. In this case, this response is captured as document error by IM, causing the Document Error event to fire.

Finally, the Integration Error event fires each time an error occurs for the integration process as a whole.

This is not to say you can't add additional information to the log at any other point or event within Integration Manager, but you will want to remember that most times when you are dealing with logs, you want to mostly target exceptions within the integration process and not necessarily every single event.

Tomorrow, I will focus on the scripting options available to enhance/customize the logs. Also remember that this and many other topics will be covered during my GPUG Summit 2014 session on Integration Manager. Please register and attend the session.

Until next post!

MG.-
Mariano Gomez, MVP
Intelligent Partnerships, LLC
http://www.IntelligentPartnerships.com