Practical Example on Dynamics Continuum Integration Library: GL Transaction Entry Integration

I got allot of questions on how to use Dynamics Continuum API for Microsoft Dynamics GP, so I decided to post this practical lesson on how to perform forms level integration between any application or data source and GL Transaction Entry form:

References:

In order to start working on the API, we need first to add Reference to Dynamics Continuum Integration Library to our application:

image

Now we have three main functions/methods that we need to use:

 

Functions/Methods:

1. ExecuteSanscript: Function executes Dexterity code and return the result, expects two parameters and returns integer that the status was successfully completed or not:

ExecuteSanscript(“Script” as String, ByRef “ErrorMessage” As String)

2. SetDataValue: Function sets value in any “fully qualified” field name, expects two parameters and returns integer that the status was successfully completed or not:

SetDataValue(“Field Name” as String, Value as String)

3. MoveToField: Moves the cursor to the field, expects only the field name as the parameter, almost equivalent to “focus field” command in Dexterity:

MoveToField(“Field Name” as String)

 

Concept:

To proceed with our task, we’ll need first to understand how it works, we’ll need to imagine that a user is working on the form and follow all the steps need to be done, for example, the user will go to date field, fill the date and leave the field so the system run all validations on date field leave, technically speaking “MoveToField” will need to be called first, then “SetDataValue” and finally “ExecuteSanScript” to run the required scripts on leaving the field.

 

Code Snippets:

 

'Define the main object
Dim objGPApp As New Dynamics.Application
 
'Variable to Handle Returned Errors Flag
Dim intErrorValue As Integer
'Variable to Handle Returned Errors Messages
Dim strErrorMessage As String
 
'Other Needed Variables
Dim strBatchID As String = "Dataset Name"
Dim SourceDocument As String = "Source Document"
Dim TrxDate As String = "01012009"
Dim ReferenceID As String = "Sample"
Dim dsDetails As DataSet
'------------------------------------------------------------------------------
'Open the GL Transaction Entry Form
intErrorValue = objGPApp.ExecuteSanscript("open form 'GL_Transaction_Entry';", strErrorMessage)
 
'------------------------------------------------------------------------------'
'Add/Update Batch to make sure its exist
'Open Batch Entry Form
intErrorValue = objGPApp.ExecuteSanscript("run script  'Expansion Button 1' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry';", strErrorMessage)
 
'Fill Batch Number
intErrorValue = objGPApp.SetDataValue("'Batch Number' of window 'GL_Batch_Entry' of form 'GL_Batch_Entry'", strBatchID)
 
'Run Batch Number Script
intErrorValue = objGPApp.ExecuteSanscript("run script 'Batch Number' of window 'GL_Batch_Entry' of form 'GL_Batch_Entry';", strErrorMessage)
 
'Fill Origin
intErrorValue = objGPApp.SetDataValue("'Origin' of window 'GL_Batch_Entry' of form 'GL_Batch_Entry'", 1)
 
'Go To Batch Comment Field
intErrorValue = objGPApp.MoveToField("'Batch Comment' of window 'GL_Batch_Entry' of form 'GL_Batch_Entry'")
intErrorValue = objGPApp.ExecuteSanscript("run script 'Batch Comment' of window 'GL_Batch_Entry' of form 'GL_Batch_Entry';", strErrorMessage)
 
'Save Batch
intErrorValue = objGPApp.ExecuteSanscript("run script 'Save Button' of window 'GL_Batch_Entry' of form 'GL_Batch_Entry';", strErrorMessage)
 
'Close form
intErrorValue = objGPApp.ExecuteSanscript("close form 'GL_Batch_Entry';", strErrorMessage)
' End Batch
'------------------------------------------------------------------------------'
 
'Add/Update Source Document  to make sure its exist
'Open Source Document Form
intErrorValue = objGPApp.ExecuteSanscript("open form 'SY_Source_Document_Setup';", strErrorMessage)
 
'Move to Source Document Field
intErrorValue = objGPApp.MoveToField("'Source Document' of window 'Source_Document_Setup' of form 'SY_Source_Document_Setup'")
 
'Set Field Value
intErrorValue = objGPApp.SetDataValue("'Source Document' of window 'Source_Document_Setup' of form 'SY_Source_Document_Setup'", SourceDocument)
 
'Run Field Script 
intErrorValue = objGPApp.ExecuteSanscript("run script 'Source Document' of window 'Source_Document_Setup' of form 'SY_Source_Document_Setup';", strErrorMessage)
 
'Go To Description Field
intErrorValue = objGPApp.MoveToField("'Source Document Description' of window 'Source_Document_Setup' of form 'SY_Source_Document_Setup'")
'Set Data Value in Description Field
intErrorValue = objGPApp.SetDataValue("'Source Document Description' of window 'Source_Document_Setup' of form 'SY_Source_Document_Setup'", SourceDocument)
 
'Run Field Script 
intErrorValue = objGPApp.ExecuteSanscript("run script 'Source Document Description' of window 'Source_Document_Setup' of form 'SY_Source_Document_Setup';", strErrorMessage)
'Save 
intErrorValue = objGPApp.SetDataValue("'Save Button' of window 'Source_Document_Setup' of form 'SY_Source_Document_Setup'", 1)
'Close Form
intErrorValue = objGPApp.ExecuteSanscript("close form 'SY_Source_Document_Setup';", strErrorMessage)
'End Source Document Adding
'------------------------------------------------------------------------------'
 
'Now we are sure that the batch number and source document are both exist, 
'so we can use both of them in our form 
intErrorValue = objGPApp.MoveToField("'Batch Number' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'Batch Number' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'", strBatchID)
intErrorValue = objGPApp.ExecuteSanscript("run script 'Batch Number' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry';", strErrorMessage)
 
intErrorValue = objGPApp.MoveToField("'Source Document' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'Source Document' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'", SourceDocument)
intErrorValue = objGPApp.ExecuteSanscript("run script 'Source Document' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry';", strErrorMessage)
'------------------------------------------------------------------------------'
'Proceed with Journal Header Fill
'Reference
intErrorValue = objGPApp.MoveToField("'Reference' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'Reference' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'", ReferenceID)
intErrorValue = objGPApp.ExecuteSanscript("run script 'Reference' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry';", strErrorMessage)
 
'Transaction Date -You need to make sure that you passed the date 
'in the correct format-
intErrorValue = objGPApp.MoveToField("'TRX Date' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'TRX Date' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry'", TrxDate)
intErrorValue = objGPApp.ExecuteSanscript("run script 'TRX Date' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry';", strErrorMessage)
'End of Journal Header
'------------------------------------------------------------------------------'
'Journal Details: in this example, I considered the data is already filled in 
'a dataset called dsDetails with the following columns:
'(AccountNumber, AccountType ('Credit', 'Debit'), AccountAmount, LineDescription)
'------------------------------------------------------------------------------'
'Loop through all details
For Counter As Integer = 0 To dsDetails.Tables(0).Rows.Count - 1
    With dsDetails.Tables(0).Rows(Counter)
'Start with Account Number
intErrorValue = objGPApp.ExecuteSanscript("focus field 'Account Number' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
intErrorValue = objGPApp.MoveToField("'Account Number' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'Account Number' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'", .Item("AccountNumber"))
intErrorValue = objGPApp.ExecuteSanscript("run script 'Account Number' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
 
'Check the account type, credit or debit
If Trim(.Item("AccountType")).ToLower = "Debit".ToLower Then
'Incase of Debit, fill debit with the amount 
intErrorValue = objGPApp.ExecuteSanscript("focus field 'Debit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
intErrorValue = objGPApp.MoveToField("'Debit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'Debit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'", .Item("AccountAmount"))
intErrorValue = objGPApp.ExecuteSanscript("run script 'Debit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
intErrorValue = objGPApp.ExecuteSanscript("focus field 'Credit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
intErrorValue = objGPApp.MoveToField("'Credit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'")
 
Else
'Incase of credit, fill credit field with the amount 
intErrorValue = objGPApp.ExecuteSanscript("focus field 'Credit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
intErrorValue = objGPApp.MoveToField("'Credit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'Credit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'", .Item("AccountAmount"))
intErrorValue = objGPApp.ExecuteSanscript("run script 'Credit Amount' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
End If
 
'Fill the distribution reference field 
intErrorValue = objGPApp.ExecuteSanscript("focus field 'Description' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
intErrorValue = objGPApp.MoveToField("'Description' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'")
intErrorValue = objGPApp.SetDataValue("'Description' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry'", .Item("LineDescription"))
intErrorValue = objGPApp.ExecuteSanscript("run script 'Description' of window 'Transaction_Scroll' of form 'GL_Transaction_Entry';", strErrorMessage)
 
'Move the scrolling window to the next line
intErrorValue = objGPApp.ExecuteSanscript("Window_ScrollScrollingWindow(window 'Transaction_Scroll' of form 'GL_Transaction_Entry', SCROLLTYPE_NEXT);", strErrorMessage)
 
End With
Next
 
'Save the Journal
intErrorValue = objGPApp.ExecuteSanscript("run script 'Save Button' of window 'GL_Transaction_Entry' of form 'GL_Transaction_Entry';", strErrorMessage) 
 
'Close GL Transaction Entry Form
intErrorValue = objGPApp.ExecuteSanscript("close form 'GL_Transaction_Entry';", strErrorMessage)
'------------------------------------------------------------------------------'
 

That's it! Let me know if you have any issues or inquiries about the above code, I will be more than happy to help.

Regards,

Mohammad R. Daoud

MVP, MCP, MCBMSP, MCTS, MCBMSS

Software Development Manager

+962 – 79 – 999 65 85

Great Package For Business Solutions

daoudm@greatpbs.com

http://www.greatpbs.com

Advertisements

About Mohammad R. Daoud
Mohammad R. Daoud has been working as a Microsoft Dynamics GP consultant since 2004. His career path started with version 7.5; he studied every single tip of the application technicalities and did allot of successful implementations that includes functional consultations, analysis, and custom development projects. He holds a graduate degree in Computer Science and currently he is pursuing MBA degree in Accounting. In January 2007 he was nominated to the Microsoft Most Valuable Professional (MVP) certificate and was certified in April 2008 due to his online contributions in the Dynamics Community (Dynamics GP Newsgroups, Forums, User Groups and his blog: http://mohdaoud.blogspot.com). Worth to mention that he was also listed as one of the Microsoft Dynamics Top 100 Most Influential People in 2009 by DynamicsWorld. And more... • Demonstrated Passion for MS Products through participating in beta testing for some product versions, an effective member of Microsoft Connect. • Talented in securing strong high quality relationships with premier customers, partners and sales teams passionately and profitably. • Dedicated to meeting the expectations and requirements of internal and/or external customers • Problem Solver – Uses systematic approach to uncover true problem(s) and practical solution and can marshal resources to solve problem! • Proven record of effective account management, including Account Planning, Opportunity Management, and Business Management Excellence and working as part of a larger virtual team • Successful in delivering high quality technical engagements in the enterprise Dynamics GP implementations area according to customer requirements. • Dedicated, Committed, Self Motivated, Creative and highly focused with excellent communication, Negotiation, presentation, Active Listening and Objection Handling skills. • Experienced in Profitable researches and studies including white papers and technical presentations.

8 Responses to Practical Example on Dynamics Continuum Integration Library: GL Transaction Entry Integration

  1. This is very usefull…

    Is it possible to upload GL Trx using this code?

    If yes could you share some knowledge on it?

    Regards,
    Santosh

  2. Santosh,

    This was the main idea of publishing the above code, just loop your data and call this code inside and enjoy.

    Regards,

  3. Anonymous says:

    Nice one! However is there any way we can disable window through sanscript?

  4. emerson says:

    Hi Sir,

    i have learned a lot from your post as a newbie in integration of dynamics gp. May i ask how to set the value of [account number] which is a composite field? im really having a hard time setting the value of account number using cintinuum library. hope you have a piece of code to do it. thanks a lot.

  5. emerson says:

    saw the piece of code sir in your example. i have to run the script of account number to set the value. thanks a lot.

  6. Anonymous says:

    This post is vary valuable fou us.
    Is the COM a common COM like ADO?
    We have a SalesLogix CRM and its opened coding area is a VBScript-based environment. We can create ADO objects and then execute those propetyies and mathods. Can we use Dynamics Continuum in our SalesLogix form like we use ADO? e.g. we have a SalesLogix form on which there is a button. When the button is clicked, the GP invoice form should be opened and popped up. Is that possible?

  7. Anonymous says:

    Sorry about the typo mistakes “propetyies and mathods”. It should be “properties and methods”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: