Here’s a very useful piece of code you can use to run a MAS 500 task without having to login manually or open the MAS 500 desktop.
Suppose you have an import task in MAS 500 which has to be executed everyday. So usually the user would have to login to MAS 500 everyday and manually run the task. This can be very arduous. If you had a utility which you can simply schedule using windows scheduler to run the MAS 500 task everyday, it would save a lot of manual labor. And that’s exactly what the following piece of information will help you with.
The following code has been done in VB.Net. You will need Visual Studio to proceed further. You will need Visual Studio 2003 for MAS 500 version 7.00 and Visual Studio 2005 for MAS 500 versions 7.05 & 7.2.
Open a new windows application project in Visual Studio.
You will need to add the following references to the project:
- Accounting.Framework.Common
- Accounting.Framework.ObjectManager
The above DLL’s can be found at ‘Program FilesSage SoftwareSage MAS 500 ClientManaged ApplicationsFramework’.
As shown in the code given below the steps to follow are:
- Create an ObjectManagerWrapper object.
- To login to Mas 500, pass required parameters to the Login function of the ObjectManagerWrapper object. The parameters are Server name, System database name, Application database name, Trusted Connection, User name, Password, CompanyID, Language ID and Login Option.
- The Login function returns a boolean value. If the boolean value returned is true, we shall go ahead with running/executing the MAS 500 task.
- Run the MAS 500 task by calling the ‘LaunchTask’ method of the OjectManagerWrapper object. You need to pass the Task ID of the MAS 500 task as an integer parameter.
- Once the task is run we can logout of MAS 500 using the Logout method of the ObjectManagerWrapper object.
Dim _ObjMgrWpr As ObjectManagerWrapper
‘Create object
_ObjMgrWpr = New ObjectManagerWrapper’Login to MAS 500
lbln_Login = _ObjMgrWpr.Login(pstr_ServerName, pstr_DBName, pstr_DBName, False, pstr_UserName, pstr_Password, pstr_CompanyID, 1033, Constants.LoginOption.ChangeAll)‘Check if login was successful
If lbln_Login = True Then‘Launch MAS 500 task
_ObjMgrWpr.LaunchTask(100000000)‘Log out of MAS 500
_ObjMgrWpr.Logout()Else
‘If login was unsuccessful, log error
End If
For any queries, feel free to contact us at sage@greytrix.com.
About Us
Greytrix is a one stop solution provider for Sage ERP and Sage CRM needs. We provide complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.
Greytrix has some unique solutions of Sage 100 integration with Sage CRM, and Salesforce.com along with Sage 100 Migration from Sage 50 US, Sage Intacct, QuickBooks, Sage Business Vision and Sage Business Works. We also offer best-in-class Sage 100 customization and development services to Sage business partners, end users, and Sage PSG worldwide.
For more details on Sage 100 Services, please contact us at sage@greytrix.com. We will be glad to assist you.