Skip to content
+1-888-319-3663

COMMUNITY FORUM

Writing to SY00500 table

Sean asked 8 years ago
I have two maps with multicurrency information being integrated into Dynamics GP2013.  The data in the upload file is in native currency with the translation to originating currency (in this case British Pounds) occuring in Dynamics GP. 

The problem I'm having is writing the batch total, which should be in GBP after translation, to the SY00500 table so it shows up in the Batch Entry screen.

Any advice on how make this happen?

Thanks,
Sean
Sherry replied 8 years ago

Sean,  I did this yesterday for updating the Post Date on the Batch in the sy00500.  Can you use this methodology – just changing the update statement to your total amount instead of post dating?     Restriction on Create Transaction Node – Cambridge is the batch ID; you could also specify a source field.                                                                                         
GlobalMessage="CAMBRIDGE"
 return true                                                                                                          SCRIPT:                        '—————————————————————————————
' Script Name: UpdatePostingDate
' Created On: 01/18/2009
' Author: Chris Hanson
' Purpose: This script updates the batch posting date in SQL Server.
' History:
 '—————————————————————————————
'—————————————————————————————
 ' Requirements: This script should be located in the Tasks -> Map -> After -> Success
 ' section of the SmartConnect map setup. In the case of this template,
' the GlobalMessage global variable is being set to the batch number
' in the restriction when the map runs, then this script uses it to
 ' update the posting date in the SY00500.
'—————————————————————————————
 '—————————————————————————————
 ' Setup: There are five variables to assign in the configuration section. The
 ' first four determine which values are used in the connection string.
 ' Those four variables – the server (data source), database (initial
' catalog), user, and password should be changed to the needed values.
' The last variable, sqlQuery, contains the query message that is going
' to be executed. This needs to be changed to reference an actual table
' and its corresponding columns before the script will run.
 '—————————————————————————————
 '———————————– CONFIGURATION ————————————-
Dim server As String = "SQLINSTANCE"
Dim database As String = "DBNAME"
Dim user As String = "USERID"
Dim password As String = "PASSWORD"
Dim sqlQuery As String = "UPDATE SY00500 SET GLPOSTDT = '" & DateTime.Now.ToString("yyyy-MM-dd 00:00:00.000") & "' where BCHSOURC = 'Sales Entry' and BACHNUMB = '" & GlobalMessage & "'"
 '—————————————————————————————
Try 'Declare the connection string based on the configuration variables
Dim conString As String = "Data Source=" & server & ";Initial Catalog=" & database & ";User=" & user & ";Password=" & password & ";"
'Define the SQL connection and open it
Dim myConn As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(conString)
myConn.Open()
'Declare the SQL command as the query string and execute it
Dim command As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(sqlQuery, myConn)
command.ExecuteNonQuery()
'Close the connection
myConn.Close()
Catch ex As Exception
Messagebox.Show(ex.Message, "UpdatePostingDate Script Error")
Return False
End Try
Return True

sean.reynolds@usrisk.com replied 8 years ago

Thanks Sherry!

Your reply was quite helpful.   I ended up executing a basic SQL command under the Tasks that run if the document succeeds item of the Document Tasks section.  

Sean

Answers
Best Answer
Chris answered 8 years ago
The only thing I would add onto Sherry's post is on the current builds of SC you can setup up a saved sql connection and use that within the script so you don't need to have unencrypted passwords sitting out in your scripts any longer.

Here is a blog we have on it:
http://eonesolutions.blogspot.com/2013/08/tech-tuesday-saved-connections-in.html

H

If you would like to submit an answer or comment, please sign in to the eOne portal.