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 to set a field value based on database value

(0) ShareShare
ReportReport
Posted on by 4

I am trying to write a VB script in Integration manager to set the shipping method on a SOP transaction (at the customer level) to the value of the shipping method in the RM00101 table for that customer. My script compiles, but the value is not getting set. I am sure I'm missing something simple, but I can't figure out the issue. Here is my script:

sCustomerID=Sourcefields("GM_INV_HDR.Customer Number")

'Open a connection to the SQL database

Set MyCon = CreateObject("ADODB.Connection")

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

GPConnection.Open(MyCon)

'Create a new recordset -- that will hold returned data

Set recset = CreateObject("ADODB.Recordset")

sSQL="SELECT SHIPMTHD 'ShipMethod' FROM RM00101 WHERE RM00101.CUSTNMBR = '"& sCustomerID & "'"

'Open the recordset using the SQL statement

set recset = MyCon.Execute(sSQL)

sShippingMethod= recset("ShipMethod")

'Close connection when finished

Call MyCon.Close

'Release the object

Set MyCon = Nothing
 

Can anyone tell me what I'm missing that it's not setting the value?

Thanks.

Debbie K.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mariano Gomez Profile Picture
    26,225 on at
    RE: Integration Manager VB script to set a field value based on database value

    Assuming the above is a field script, here's what you are missing:

    set recset = MyCon.Execute(sSQL)
    sShippingMethod= recset("ShipMethod")
    CurrentField.Value = sShippingMethod

    If the above script is attached to a different event, please let me know as you may need to assign the Shipping Method result to a global variable, and in the field script, read the global variable.

  • Alison Guimond Profile Picture
    10 on at
    RE: Integration Manager VB script to set a field value based on database value

    Hi Debbie,

    It looks like you are missing a line to set the field value, assuming this script is at the field level.  After the line where you set sShippingMethod= recset("ShipMethod"), you would need something like this:  CurrentField=sShippingMethod

    -Alison

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