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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Integration Manager Script

(0) ShareShare
ReportReport
Posted on by

Hi Forum,

I am receiving the following error when I run an integration containing a script. The script says it has compiled successfully and is to populate the Item Resource Planning window of Inventory Item Cards. Any assistance would be appreciated

Object reference not set to an instance of an object.

Error Compiling Script 'After Document' Line 2: - Expected end of statement

Expected end of statement

The script is as per below

strSQL = "MyCon.ConnectionString = 'database=' & GPConnection.GPConnInterCompanyID " & _

              "GPConnection.Open(MyCon) " & _

              "Update IV00102 " & _

              "set ORDERPOLICY = SourceFields('AH Inventory Item.Order Policy') " & _

              "Where ITEMNMBR = SourceFields('AH Inventory Item.Item Number'), LOCNCODE = SourceFields('AH Inventory Item.Site') " & _

              "set MNMMORDRQTY = SourceFields('AH Inventory Item.Min Order Qty') " & _

              "Where ITEMNMBR = SourceFields('AH Inventory Item.Item Number'), LOCNCODE = SourceFields('AH Inventory Item.Site') " & _

              "set MXMMORDRQTY = SourceFields('AH Inventory Item.Max Order Qty') " & _

              "Where ITEMNMBR = SourceFields('AH Inventory Item.Item Number'), LOCNCODE = SourceFields('AH Inventory Item.Site') " & _

              "set ORDERMULTIPLE = SourceFields('AH Inventory Item.Order Multiple') " & _

              "Where ITEMNMBR = SourceFields('AH Inventory Item.Item Number'), LOCNCODE = SourceFields('AH Inventory Item.Site') " & _

              "set FXDORDRQTY = SourceFields('AH Inventory Item.Fixed Order Qty') " & _

              "Where ITEMNMBR = SourceFields('AH Inventory Item.Item Number'), LOCNCODE = SourceFields('AH Inventory Item.Site') " & _

              "set ORDRPNTQTY = SourceFields('AH Inventory Item.Order Point Qty') " & _

              "Where ITEMNMBR = SourceFields('AH Inventory Item.Item Number'), LOCNCODE = SourceFields('AH Inventory Item.Site') " & _

              "set ORDRUPTOLVL = SourceFields('AH Inventory Item.Order-Up-to-Level') " & _

              "Where ITEMNMBR = SourceFields('AH Inventory Item.Item Number'), LOCNCODE = SourceFields('AH Inventory Item.Site') " & _

              ""

Categories:
I have the same question (0)
  • Suggested answer
    Derek Albaugh Profile Picture
    Microsoft Employee on at

    It appears that it has an issue with Line 2 of the script, which looks to be this line:

              "GPConnection.Open(MyCon) " & _

    Are we missing the line to close the connection? i.e. MyCon.Close

    RE: learn.microsoft.com/.../gpconnection-object-replaces-retrieveglobals-dll

    I'm also wondering if you need the &_ after the GPConnection.Open(MyCon) line?

    In most cases, we see the scripts written such as this example:

    GPConnection.Open(MyCon)

    IF IsNULL(sourcefields("ABS - Warehouse PO Line Items.LEGACYPRODUCTCODE"))= True Then

         itemString= Sourcefields("ABS - Warehouse PO Line Items.SUPPLIERPRODUCTCODE") + "-" + Sourcefields("ABS - Warehouse PO Line Items.SUPPLIERPRODUCTSIZE")

    Else

         itemString= sourcefields("ABS - Warehouse PO Line Items.LEGACYPRODUCTCODE")

    End If

       cmdString = "Select ITEMNMBR from dbo.IV00101 where (ITEMNMBR='" + itemString + "')"

       Set recset = MyCon.Execute(cmdString)

       If recset.BOF And recset.EOF Then

           'The end of the IV00101 listing was reached so item is non-inventoried

         CurrentField.Value=1

       Else

         'An entry in the IV00101 listing was found so item is inventoried

           CurrentField.Value=0

       End If        

           MyCon.Close

    I imagine there are many ways to script it out and the Community may have more ideas as to your error message.

    Thanks

  • GV1 Profile Picture
    on at

    Thank-you Derek, I really appreciated you taking the time to read and advise on the post. Much appreciated

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 681 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 598 Super User 2026 Season 1

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 579

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans