If you are one of the fervourous Integration Manager fans out there and have had to work on integrating journal entries with Analytical Accounting information, you may know this is only possible with the eConnect Adapter, not the Standard Adapter.
The eConnect Adapter was introduced with Integration Manager version 10, and replaces the old SQL Optimized Adapter available in prior versions of Integration Manager. The eConnect Adapter in turn, leverages eConnect components to deliver a robust transactional environment for high volume integrations using ADO.NET to access Microsoft Dynamics GP company databases.
![]() |
| eConnect Adapter - Journal Entry# field with Use Default rule value |
However, the eConnect Adapter, though, while it provides a Use Default rule value for the Journal Entry# field, this setting causes the integration to fail, as eConnect (the component) requires a value to be supplied, this is, the actual journal number.
Of course the question now is, how do you retrieve the next journal number from your company database to supply this value to the Journal Entry# field to allow the integration to be successful and thereby, preventing you from having to manually reserve ? The answer is, scripting, of the VBScript type.
You can add VBScript code to the Before Document event script in Integration Manager to retrieve the next journal number from your company database, as follows:
' Created by: Mariano Gomez, MVP
' This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Generic license.
Option Explicit
Const adCmdStoredProc = 4
Const adParamInput = 1
Const adParamOutput = 2
Const adParamInputOutput = 3
Const adInteger = 3
Const adVarchar = 200
Const adBoolean = 11
Const adChar = 129
Const adDate = 7
Const adNumeric = 131
Dim SqlStmt
Dim objConnection, objCommand, NextJournal
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open _
"Provider=SQLNCLI10;Server=MGB001\GP11;Database=TWO; Trusted_Connection=yes;"
With objCommand
.ActiveConnection = objConnection
.CommandType = adCmdStoredProc
.CommandText = "glGetNextJEWrapper" 'our wrapper stored proc
.Parameters.Append .CreateParameter ("@IO_iOUTJournalEntry", adInteger, adParamOutput, 4)
.Parameters.Append .CreateParameter ("@O_iErrorState", adInteger, adParamOutput, 4)
.Execute
NextJournal = objCommand.Parameters("@IO_iOUTJournalEntry").Value
End With
SetVariable "gblJournal", NextJournal
Set objCommand = Nothing
Set objConnection = Nothing
The above code calls the stored procedure dbo.glGetNextNumberWrapper, which leverages the existing Microsoft Dynamics GP's dbo.glGetNextJournalEntry stored procedure to retrieve the next journal number, stored in the dbo.GL40100 (General Ledger Setup) table. As this is a call to a standard Microsoft Dynamics GP stored procedure, we are avoiding the use of custom code to retrieve the journal number and increment the value at the same time.
It is also necessary to note that the above code uses a Trusted Connection to connect to the company database. You can change the connection string as you see fit, just keep in mind that if you are going to use a SQL login, it cannot be a Microsoft Dynamics GP user login as the password for these logins are encrypted on SQL Server.
The following is the code for the dbo.glGetNextNumberWrapper stored procedure called by the Before Document script:
IF OBJECT_ID('dbo.glGetNextJEWrapper') IS NOT NULL
DROP PROCEDURE glGetNextJEWrapper;
GO
CREATE PROCEDURE glGetNextJEWrapper
@IO_iOUTJournalEntry int OUTPUT,
@O_iErrorState int OUTPUT
AS
DECLARE @l_tINCheckWORKFiles tinyint = 1, @I_iSQLSessionID int = USER_SID(), @O_tOUTOK tinyint;
IF @IO_iOUTJournalEntry IS NULL
SET @IO_iOUTJournalEntry = 0
EXECUTE glGetNextJournalEntry
@l_tINCheckWORKFiles
,@I_iSQLSessionID
,@IO_iOUTJournalEntry OUTPUT
,@O_tOUTOK OUTPUT
,@O_iErrorState OUTPUT
GO
GRANT EXECUTE ON glGetNextJEWrapper TO DYNGRP;
For more information on connection strings, visit http://www.connectionstrings.com/. Also, check the following article over at Developing for Dynamics GP on why does Microsoft Dynamics GP encrypts passwords.
Once the Before Document event script is implemented, you can then add a small field script to the Journal Number field to retrieve the value stored in the gblJournal Integration Manager global variable, as follows:
' Created by: Mariano Gomez, MVP
' This code is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Generic license.
CurrentField.Value = GetVariable("gblJournal")
Integration Manager has great import capabilities when combined with the power of scripting and when you have a clear understanding of the underlaying technologies that support it.
Please enter your comments on this article or any methods you have used in the past to overcome similar issues.
Until next post!
MG.-
Mariano Gomez, MVP
IntellPartners, LLC
http://www.IntellPartners.com/
Edits:
05/25/2011 - fixed IM global variable name as it was not matching between the Before Document script and the Journal Number Field Script, causing nothing to be assigned to the field and erroring out the integration.

0 comments:
Post a Comment