web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Integration Manager VB Script help - validate accounts in file before running IM

(0) ShareShare
ReportReport
Posted on by 81

I am trying to create an integration that will load expense transactions into GP as a j/e.  I have the basic integration working, but now need to add a before script to validate that the account in the source file exists in GP, if not, throw an error.  I was given a very vague sample of code, but am having a hard time deciphering it.  I don't know VBS. Can someone please share what they can to get me going in the right direction?  We have a SQL db.  Any samples and information would be appreciated.  Can you break down the pieces I need, such as, create new connection, open db, etc.?  Thank you in advance.

*This post is locked for comments

I have the same question (0)
  • Mick Egan Profile Picture
    3,561 on at
    RE: Integration Manager VB Script help - validate accounts in file before running IM

    This might assist as a starting point, you can add additional code.

    Set MyCon = CreateObject("ADODB.Connection")

    'Open the connection to the database - TWO is my database

    MyCon.ConnectionString = "TWO=" & GPConnection.GPConnInterCompanyID

    GPConnection.Open(MyCon)

    'Build a string containing your SQL Select Statement

    sSQL = "SELECT ACTNUMST from GL00105 where ACTNUMST = '"

    sSQL = sSQL & SourceFields("Accounts.Account Number") & "'"

    'If you're having trouble getting your SQL statement correct,

    'then un-comment the following "MsgBox" line by removing the

    'single-quote character.  This will generate a message box

    'containing your SQL statement every time the script is run.  

    'After you've corrected any errors, add the single-quote back

    'to the beginning of the line.

    'MsgBox ("The SQL statement is: " & sSQL)

    'Open the recordset

    Set recset = MyCon.Execute(sSQL)

    'Test to see if any records were matched to an exisitng account

    If Not recset.EOF Then

    MsgBox "Account Number " & sAccount  & " Already Exists"

    CancelDocument sErrMsg

    Else

    'do nothing

    End If

    'Close the connection

    Call MyCon.Close

    'Release the object

    Set MyCon = nothing

    -----------------------------------------------------'

    Mick

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans