| Sreenath Reddy's profileSreenath Reddy G - DAX C...BlogListsNetwork | Help |
Sreenath Reddy G - DAX Consultant |
|||||||||||||||||||||||||
|
September 17 Alert user using Net send - x++Sending messages to the users in network using NET SEND in x++ Microsoft Windows offers a simple method to send messages to other users or computers on the network - simple WinPopup Messages or Net Send Messages ( in Windows 95, Windows 98, Windows Me, Windows NT, Windows 2000, Windows XP and Windows 2003 ). Prerequisite: Start Messenger service from Start >> Programs >> Administrative tools >> messenger. Here is the job which will send messages to the users/computers on the network. static void netSend(Args _args) { COM netSendCom; InteropPermission permission = new InteropPermission(InteropKind::ComInterop); int output; //str computerName = 'giri'; str computerName = Winapi::getComputerName(); str message = 'Hello.. I am alerting from Dynamics AX'; // Receiving end should start messenger service and alerter service from services.msc permission.assert(); try { netSendCom = new COM("WScript.Shell"); output = netSendCom.Run(strFmt("net send %1 %2", computerName, message),0,true); } catch (Exception::Error) { CodeAccessPermission::revertAssert(); throw Exception::Error; } if (output != 0) { warning(strfmt('Net send Failed', computerName)); warning('Check messenger service - Started'); } CodeAccessPermission::revertAssert(); } Here is the net send message popup August 08 Generate XML Documentation Files for a project - DAX 2009To generate XML documentation files for a project
To generate XML documentation files for the entire applicationCreate a folder in which you will create the XML documentation files. This procedure will reference a folder that has the path, C:\XMLDoc.Note: For security purposes, you may not be able to create XML documentation files directly on the root of a drive. At the command prompt, execute the following command to create a documentation file for the entire application: Ax32.exe -startupcmd=xmldocumentation_C:\XMLDoc\documentation.xml At the command prompt, execute the following command to create a reflection file for the entire application: Ax32.exe -startupcmd=xmlreflection_C:\XMLDoc\reflection.xml Note :When you use these commands, Microsoft Dynamics AX will automatically start and create the XML files. Microsoft Dynamics AX will automatically close when it finishes. May 02 Get the Exchange Rates for the given Currency using X++I did MSN search and found a public web service; webservicex.net that provides a public currency converter web service. This code snippet accesses a public web service to get the exchange rate for a given currency using x++. static void GetExchangeRates(Args _args) { com com = new com('microsoft.xmlhttp'); com com1; XMLDocument xmlDoc; Dialog exchDialog = new Dialog("Exchange Rates"); DialogField fromField; DialogField ToField; str url; ; fromField = exchDialog.addField(Types::String, 'Base Currency'); fromField.value(CompanyInfo::find().CurrencyCode); ToField = exchDialog.addField(Types::String, 'To Currency'); if(exchDialog.run()) { url = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?";
com.send(); com1 = com.responsexml(); xmlDoc = XmlDocument::newXml(com1.xml()); info("1 "+fromField.value() + " = " +xmlDoc.getNamedElement('double').text() + " " +ToField.value()); } } For more information on the web service, methods and the supported currencies Click here April 30 Create Outlook Appointment or Meeting Request using X++If you need to create an appointment or meeting request in Outlook using X++, just borrow the code below. Outlook client needs to be installed on the machine where the code is run. Here is the job. static void OutlookAppointment(Args _args) { COM sysOutlookCollection; COM collection; COMVariant comStartDate = new COMVariant(); COMVariant comEndDate = new COMVariant(); COM c; #SysOutLookCOMDEF #define.mapi("MAPI") #define.outlook("Outlook.Application") COM sysOutlook; COM sysOutlookNameSpace; COM sysOutlookMAPIFolder; ; sysOutlook = new COM(#outlook); sysOutlookNameSpace = sysOutlook.getNamespace(#mapi); sysOutlookNameSpace.logon(); sysOutlookMAPIFolder = sysOutlookNameSpace.getDefaultFolder(#OlDefaultFolders_olFolderCalendar); collection = sysOutlookMAPIFolder.items(); c = collection.add(); comStartDate.date(today()); comStartDate.time(str2Time( "12:00:00")); comEndDate.date(today()); comEndDate.time(str2Time( "12:45:00")); c.location('Solugenix 4th Floor Conference Room, India'); c.subject('Meeting regd Microsoft Dynamics AX 2009'); c.body('Lets discuss on whats new in DAX 2009'); c.start(comStartDate); c.end(comEndDate); c.save(); if (c) { c.display(); info("The action is created in Microsoft Outlook"); } else throw error("@SYS31969"); sysOutlookNameSpace.logoff(); }
Problem when creating a dynamic form with ActiveX control & Solution :)The Requirement was to connect to the web and get the content of the web page and display it on the form .Well, I did not want to create a form in AOT to display the HTML content .So , I thought of dynamically creating a form and adding the browser ActiveX Control using X++ code. Here is the code which I pasted in the job. static void ActiveX_DynamicForm(Args _args) { COMDispFunction webpreviewWrite; COMVariant text = new COMVariant(); COM ctrl = new COM(); Form formBrowse; FormActivexControl activex; FormRun formRun; Args args; int handle; WinInet wi = new WinInet(); str htmlContent; ; handle = wi.internetOpenUrl('http://www.yahoo.com'); if (handle) { htmlContent = wi.internetReadFile(handle); }
wi.internetCloseHandle(handle); formBrowse = new Form('ActiveX AX Form', true); formBrowse.design().width(500); formBrowse.design().height(500); formBrowse.design().addControl(FormControlType::ActiveX, 'Browser'); args = new Args(formBrowse.name()); args.name(formBrowse.name()); args.object(formBrowse); formRun = classFactory.formRunClass(args); formRun.init(); activex = formRun.design().controlName('Browser'); activex.className('{8856F961-340A-11D0-A96B-00C04FD705A2}'); activex.height(1,1); activex.width(1,1); formRun.run(); ctrl.attach(activex.interface()); webpreviewWrite = new COMDispFunction(ctrl, 'write', COMDispContext::Method); text.bStr(htmlContent); activex.open(""); webpreviewWrite.call(text); formRun.detach(); } I was successful in creating the form but strangely AX threw me an error when I ran the code. It was not supporting ‘write’ method for automatic interface of COM object of class “IWEBBrowser2’ I did not want to create a separate form adding an ActiveX control to achieve this. I looked for alternatives and found one interesting class which served my purpose. Class Name: KMKnowledgeFunctionShow Method : static Object show(TextBuffer htmlText, Object _formRun = null) The show method will open the standard “KMKnowledgeAnalogMeter” form which has an ActiveX Control added to it. I got the content of the webpage and added it to the TextBuffer by using settext() method and passed the TextBuffer to the show method. I did not pass the second parameter formrun. The idea behind this is to open the existing Standard form which has already Browser ActiveX in it. Here is the code static void ActiveX_Alternate(Args _args) { str htmlContent; TextBuffer txtBuffer; int handle; WinInet wi = new WinInet(); ; handle = wi.internetOpenUrl('http://www.yahoo.com/'); if (handle) { htmlContent = wi.internetReadFile(handle); } txtBuffer = new TextBuffer(); txtBuffer.setText(htmlContent); KMKnowledgeFunctionShow::show(txtBuffer); } Drawback: The form caption stills remains the “KMKnowledgeAnalogMeter “form caption Attached is the error and the output of the second job |
Links related to Microsoft Dynamics AX
|
||||||||||||||||||||||||
|
|