Monday, December 26, 2011

How to create a dialog box in a report

public class ReportRun extends ObjectRun
{
    ItemGroupId itemGroup;
    DialogField dialogItemGroup;
}
public Object dialog(Object _dialog)
{
    DialogRunBase dialog;
    ;
    dialog = super(_dialog);
    dialog.caption("Inventory");
    dialog.addGroup("Item Group");
    dialogItemGroup = dialog.addFieldValue(typeid(ItemGroupId),itemGroup,"Item Group");
    return dialog;
}
public boolean getFromDialog()
{
    ;
    itemGroup   = dialogItemGroup.value();
    return true;
}
public boolean fetch()
{
    Query                   q;
    QueryRun                qr;
    QueryBuildDataSource    qbds;
    QueryBuildRange         qbr;
    ;
    q       = new Query(this);
    qbds    = q.dataSourceTable(tablenum(InventTable));
    qbr     = qbds.addRange(fieldnum(InventTable,ItemGroupId));
    qbr.value(itemgroup);
    qr      = new QueryRun(q);
    while( qr.next() )
    {
        inventTable = qr.get(tablenum(InventTable));
        this.send(inventTable);
    }
    return true;
}

Note: for reference you can check LedgerCheckTrans report

Friday, December 23, 2011

AX in Hindi

Guys this is what AX is in hindi, after running the hindi script in microsoft. I found it funny so sharing with you guys.

Check for empty values inside a query

Suppose we need to check/filter data inside the tabel on the basis of null values, or we need to fetch the data from a table where the value of the field is null.

sysQuery::valueEmptyString for the select query to fetch the data from the table where there is no value for the selected record.

sysQuery::valueNotEmptyString for filtering data where there is value in the field, this will fetch only those records for which there is value.

For example, we can use this inside filter query on datasources of the form, inside the init or execute query methods.

QueryBuildRange        QueryBuildRange;
;
QueryBuildRange = this.query().dataSourceTable(tablenum(CustTable)).
           addRange(fieldnum(CustTable, AccountNum));
QueryBuildRange.value(sysQuery::valueNotEmptyString());

This will only display non empty records on the form grid.

Reference: http://msdn.microsoft.com/en-us/library/aa866017(v=ax.50).aspx

Thursday, September 22, 2011

Importing data into microsoft dynamics AX


The way one can import data into microsoft dynamics ax from a .dat file is
1. Navigation Pane->administrator-> periodic-> import data
2. then selecting the dat file to capture the data into AX.
3. Once the .dat file is loaded we can make a batch job to update the table or else we can do it manually as well.

But if the data is huge it will take forever to load the data because it does all the validations for each data while uploading it.But there is a fix.

Note: Before following these steps make sure you have your database backed up because this steps overwrite the existing data

->unzip and keep the data into one of the drives(c:)
-> once you have the .dat file then open Microsoft SQL Server Management Studio
-> In the Object explorer window select the database for AX.
-> Right click the database and select Restore Database
-> in Select Page window select General menu
-> On the source for restore, select the radio button From device:
-> By clicking on the browse button to the right of the option , give the path of the .bat file.
-> Your database will get listed at the bottom of the screen
-> Select the Options menu on the Select a Page tab again(near General menu)
->one the page select overwrite existing data check box
-> and click OK

It will take few minutes to load the data directly into the database, once it is complete you can start the AOS services again.

I found the find() method

           When i was learning the basics of Microsoft dynamics AX. I never came accross the find method, which later i found was really useful to create a structure on your programming. For example, we can use find methods on tables, which can be called using class or form methods. This gives a structure to the programming and also boosts performance of the code, since all the select queries are run on the server rather than calling from the form or the class. Since the find method returns a single record which can be saved into a tables buffer. Table buffer can then be passed to different methods wherever there is a requirement for that record values. pretty neat han!

Sunday, September 11, 2011

Java is Highly Vulnerable to Reverse Engineering

Found an article on Java which I found interesting(msdynamicsworld.com)

Java is Highly Vulnerable to Reverse Engineering

While the ability to “Write Once, Run Anywhere” is a tremendous advantage, the way this environment is architected renders it far easier for hackers to reverse engineer than native applications. This means that developers face the very real risk of losing their intellectual property. There are a number of reasons why application-based virtual machines are easier to reverse engineer than native applications:

JVM is open source
Sun has made the source code freely available for the JVM. This makes it simple for hackers to simply look at the code to see exactly how the virtual machine works.

The Java .class file format is publically available
As mentioned earlier, Java source code is compiled into byte code, which is stored in a Java .class file. The specification of the Java .class file format is publicly available, making it easy for anyone with some technical background to write a tool that can process, modify, or transform the .class files.

The JVM is software, not hardware
Unlike standard programming languages that require an expert understanding of the specific processor, the JVM is an application that acts like a microprocessor and uses built-in capabilities provided by the operating system and computer hardware. Because hackers do not have to step down to the hardware level, it is easier to gain full control over the JVM.
Thus, for example, when debugging with standard native system development languages, pausing the processor is extremely difficult, requiring expert knowledge of the processor, the debugging capabilities, and the available ring-debuggers. However, because the source of the JVM runtime environment is openly available, a developer can easily build his or her own virtual machine that provides full control over every aspect of the virtual processor. This makes it easy to analyze every application running in the runtime environment.

Thursday, September 1, 2011

Microsoft Dyanmics AX in comparison with Oracle and SAP on Cloud Computing

Joshua Greenbaum has commented on the advantage Microsoft Dyanmics AX has over Oracle and SAP in Cloud Computing market.

http://ematters.wordpress.com/2011/04/14/converging-giants-microsoft-dynamics-lines-up-against-sap-oracle-and-salesforce-com/

Thursday, July 14, 2011

Runbase Framework Example

1. Create a base enum having Show and Hide values.
2. Create a class
class SelectShowClass extends RunBase
{
DialogField SelectField;
DialogField DisplayField;
}
3. Write a dialog method in class
public object dialog()
{
Dialog dialog;
;
Dialog=super();
SelectField = dialog.addField(typeid(SelectShow));
DisplayField = dialog.addField(typeid(Name));
dialog.allowUpdateOnSelectCtrl(true);
return dialog;
}
4. write method dialogSelectCtrl
public void dialogSelectCtrl()
{
if(SelectField.value())
{
DisplayField.visible(false);
}
else if(!SelectField.value())
{
DisplayField.visible(true);
}
}
5.write method pack and unpack
 public container pack()
{
return connull();
}
  public boolean unpack(Container con)
{
return true;
}
6. Create a main method
 static void main(Args _args)
{
SelectShowClass SSC = new SelectShowClass();
;
SSC.prompt();
}

70 interview questions in microsoft dynamics AX

1. Major customization on forms, tables (That you have faced)

2. What is cluster installation?

3. Table collections?

4. Steps in creating number sequence?

5. Any module you are good at.

6. Collection classes

7. Tables in inventory

8. If you manipulate anything which layer would it affect?

9. Steps in data migration.

10. How to add a lookup in a form

11. What is temporary table and in which context is it used?

12. What are the components in reports?

13. How many types of classes are there?

14. RunBase framework and runbase classes

15. Development tools

16. Communication tools

17. Difference between auto generated specs and generated design specs

18. Display and edit method.

19. Can you say few best practises in ax.

20. Elements in AOT.

21. Can you have graphical representation of ssrs?

22. Steps for ssrs.

23. Steps in ssas.

24. What is the difference between sql queries and dynamics queries.

25. What is the difference between x++ and c#?

26. Installation steps in ax.

27. Difference between doupdate and updates

28. Different delete actions

29. Active, Passive, Delayed joins

30. What can’t you store in containers

31. Difference between arrays and containers

32. Logic for converting string to uppercase

33. Override methods in tables, forms

34. What is super() used for?

35. What is init method?

36. What are the sequence of methods while running a report?

37. What is EDT?

38. What is JumpRef()?

39. About form/ reports/ tables methods.

40. D.B Abstract and final class.

41. D.B ValidateWrite and write.

42. What is dialoge class.

43. Pack and Unpack method.

44. Number of elements in enum.

45. Architecture of MS dynamics AX.

46. Tell us about AIF(MSMQ).

47. What is perspectives?

48. How to design a form in AX using X++?

49. What is report builder?

50. What is Index, properties in Index and types of Index?

51. Any knowledge about Share Point.

52. Concept of Different Layer in AX.

53. difference between temporary table and container?

54. difference between bound and unbound controls?

55. what are maps and which method we use in maps?

56. classes in AIF?

57. how to create runtime query?

58. difference between pass by reference and pass by value?

59. types of relations(normal,field fixed,related field fixed)?

60. what are delete actions?

61. how to access tables of different companies(crosscompany)?

62. What is optimistic concurrency control?

63. What are transactions?

64. how to lock a transactions?

65. what are macros?

66. what is the default link type property?

67. difference between validate write and validate field?

68. Do we have validate write and validate field in form level?

69. what are the methods required for posting a purchase order?

70. how to give null in select query?

For answers check out this link.

Creating purchase orders using Excel files

Using this program you can create invoiced purchase orders using excel files.

static void createPo2(Args _args)
{
NumberSeq numseq;
PurchTable purchTable;
PurchLine purchLine;
PurchFormLetter purchFormLetter;
Dialog dialog;
DialogField dialogField;

int i,j;
    CCADOConnection  adoConnection;
    CCADOCommand    adoCommand;

    CCADORecordSet   adoRecordSet;
    CCADOFields      adoFields;
    CCADOField       adoField;

;
    adoConnection = new CCADOConnection();
    adoRecordSet = new CCADORecordSet();
    adoConnection.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= 'c:\\file.xls' ;Extended Properties='Excel 8.0;HDR=No;IMEX=1'");
    adoCommand = new CCADOCommand();
    adoCommand.activeConnection(adoConnection);
    adoCommand.commandText(@"SELECT * FROM [SHEET1$]");



ttsbegin;
numseq = NumberSeq::newGetNumFromCode(PurchParameters::numRefPurchId().NumberSequence,true);

//initialize purchase order values
purchTable.initValue();
purchTable.PurchId = numseq.num();
purchTable.OrderAccount = '1002';
purchTable.initFromVendTable();

if(!purchTable.validateWrite())
{
throw Exception::Error;
}
purchTable.insert();

//Inserting Purchase Lines
  adoRecordSet = adoCommand.execute();
  while(!adoRecordSet.EOF())
    {
        adoFields = adoRecordSet.fields();
         i=0;
   
        while(i<adoFields.count()-1)
        {

        purchLine.clear();
        purchLine.PurchId = purchTable.PurchId;

        purchline.ItemId = adoFields.itemIdx(i).value();
        i++;
        purchline.PurchQty = adoFields.itemIdx(i).value();
        purchLine.createLine(true,true,true,true,true,false);

        }
        adoRecordSet.recordSet().moveNext();

    }
//invoiceing the entries using purchFormLetter Class

purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable,"Inv_"+purchTable.PurchId,systemdateget());

if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
}
}

Thursday, June 9, 2011

Store image in table

Create a table with Container Datatype
IN form take a method getImage() write the following code.
_path = "Image path"
void getImage()
{
Bindata binData = new BinData();
FilePath _path;
ImageStore _ImageStore;

;
_path = "D:\India_flag.gif"; // file path
binData.loadFile(_path);

_ImageStore.ItemImage = binData.getData();
_ImageStore.doInsert();
}
__
take a button and call this method there:
void clicked()
{
super();

element.getImage();
ImageStore_ds.executeQuery();

}

Saturday, April 16, 2011

Not able to access Role Center page in Microsoft Dynamics AX 2009 VPC 3.5

I was trying to install Role Centers on the default home page on Microsoft Dynamics AX 2009 where i was getting a message.




To resolve this issue i searched over google and found a good article which tells how to enable the Role Centers in Microsoft dynamics AX 2009.


1. We need to start three services in windows Server services

-SQL Server Analysis Services
-SQL Server Reporting Services
-World Wide Web Publishing Service
 
https://community.dynamics.com/product/ax/f/33/t/24013.aspx
 
2. Then we need to make an entry in the host file for the Enterprise portal. Refer the following.
 

Go to C:\Windows\System32\drivers\etc and Open the hosts file using notepad

Add one record in the bottom

127.0.0.1                 sharepoint 
 
3. Then we need to create a new page and add it as a role center in microsoft dynamics ax 2009. Follow the steps given in the link below.
 
http://dynamic-ax.co.uk/Documents/How%20to%20Create%20a%20New%20Role%20Centre%20in%20Dynamics%20AX%202009.pdf
 
or
 
http://www.host-files.com/i/download.php?file=835RoleCenter.PDF
 

4. If you are getting an error "Error in Url property error"
while clicking on the URL property then you need to download a patch for the resolution.
 
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=17c36612-632e-4c04-9382-987622ed1d64
 
5. Go to Navigation Pane and select Administration-> Setup-> User Profile


6. Add a new record by clicking Ctrl+N or the new button. Fill in the details and in the Role Center Field give name of the page that your have created previously.



7. Click on the button 'Add User' and select the companies.


8. Select the Users to add and click 'ok'.




9. After these steps changed the 'Default Role Center' to your page name and click 'ok'.
 
 
10. Restart Microsoft Dynamics AX 2009 application and you will be able to see the Role Center Page that you have created.

Tuesday, April 12, 2011

How to get a number sequence for the POS module.



1. Create an element in base enum NumberSeqModule as POSModule.
 
2. Create a class NumberSeqReference_POSModule

 
public class NumberSeqReference_POS extends NumberSeqReference
{
}
 
3. Create two methods inside the class LoadModule() and NumberSeqModule().

 
protected void loadModule()
{
NumberSequenceReference numRef;
;
numRef.DataTypeId = typeId2ExtendedTypeId(typeid(POSRegisterID));
//POSRegisterId is the Extended data type
numRef.ConfigurationKeyId = configurationkeynum(logisticsBasic);
numRef.ReferenceHelp = literalstr("For POS Register ID");
numRef.WizardManual = NoYes::No;
numRef.WizardAllowChangeDown = NoYes::No;
numRef.WizardAllowChangeUp = NoYes::No;
numRef.SortField = 1;
this.create(numRef);
}

static NumberSeqModule numberSeqModule()
{
return NumberSeqModule::POSModule;// this is the element in base enum that you have created before
}
 
4. Modify the NumberSeqReference Class and change the Construct() and ModuleList()

 
//construct:
// POS addition begin
case (NumberSeqReference_POS::numberSeqModule()): return new NumberSeqReference_POS(_module);
// POS addition end

//Module List:
// POS Begin
moduleList += NumberSeqReference_POS::numberSeqModule();
// POS End
 

5. Create a class on the POSTableForm

 
public class FormRun extends ObjectRun
{
NumberSeqFormHandler numberSeqFormHandler;
}
 
6.Create a Method in the Table POSRegisterTable as numRefPOS()

 
client server static NumberSequenceReference numRefPOS()
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(POSRegisterId)));
}
 
7. Create a new method for the class

 
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler = NumberSeqFormHandler::newForm(POSRegisterTable::numRefPOS()
.NumberSequence,
element,
POSRegisterTable_DS,
fieldnum(POSRegisterTable, RegisterId)
);
}
return numberSeqFormHandler;
}
 
8. Override create method on the POSRegisterTable in the datasource methods

 
void create(boolean append = false,
boolean extern = false) // If created externally
{
;

super(append);

if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate();
}
}
 
9. Override write method on the POSRegisterTable in the datasource methods

 
void write()
{
boolean updateCurrency;
NoYes newRecord;
;
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
 
10. Override delete method on the POSRegisterTable in the datasource methods

 
void delete()
{
FormDataSource callerDataSource;
;
element.numberSeqFormHandler().formMethodDataSourceDelete();

if (!posRegisterTable.RecId)
{
DirParty::showHideMessageBar(element,posRegisterTable,true);
}

super();

if (element.args() && element.args().dataset() == tablenum(smmBusRelTable))
{
callerDataSource = element.args().record().dataSource();
if (callerDataSource)
{
callerDataSource.executeQuery();
}
}
}
 

Tuesday, April 5, 2011

Microsoft Certifications

Use the link below to go to the Microsoft Dynamics AX 2009 certification page from Microsoft.

http://www.microsoft.com/learning/en/us/certification/dynamics-ax-professional.aspx#tab2

Friday, April 1, 2011

How to call Print JobSettings using a button

Adding Print Job Settings to a button on your form in microsoft dynamics AX On the click event of the button you need to write the code:

Args args = new Args(reportstr(POSReciept));
PrintJobSettings printJobSettings;
ReportRun reportRun;
;
printJobSettings = new PrintJobSettings();
printJobSettings.SetTarget(PrintMedium::Printer); printJobSettings.suppressScalingMessage(true);

reportRun = new ReportRun(args);
reportRun.setTarget(PrintMedium::Printer);
reportRun.init(); reportRun.run();

Thursday, March 31, 2011

How to add methods to Forms

How to add methods to forms in Axapta?
Here i will show you how to get data from a particular field. Let us suppose that the new text box that you have created is intEdit which is a integer type text box in Morphx and on clicking of a button you want to get the data from a field then. Override the click method of a button and write in there.

intEdit.valuestr();

This line will capture the value of the text box intEdit.

Now, i will show you how to send a text to a form. Suppose you have a textBox of integer type intEdit and you need to send the data to that box using a button then, override the click method of the button and put in there.

intEdit.text(str2int("Hello"));

This will first convert the string to integer value and then send the data to the text box of integer type.

Note: Dont forget to change the Autodeclaration Property of the control to YES