2012年4月29日星期日

How to Overload lookup,modified and validate event in class[RunBase]

1.extends runbase
class THK_DialogSelectiveLookup extends RunBase
{
    FormStringControl   custGroupCtrl, customerCtrl;
    custGroupId         _custGroupId;
    custAccount         _custAccount;
    #define.CurrentVersion(1)
    #define.Version1(1)
    #localmacro.CurrentList
        _custGroupId,_custAccount
    #endmacro
}
2.Dialog
protected Object dialog(Dialog dialog, boolean forceOnClient)
{
    DialogRunBase ret;
;
    ret = super(dialog, forceOnClient);
    ret.caption("Test lookup in Dialog");
    custGroupCtrl = ret.formBuildDesign().addControl(FormControlType::String, 'CustGroup');
    custGroupCtrl.extendedDataType(extendedTypeNum(custGroupId));
    custGroupCtrl.text(_custGroupId);
    customerCtrl = ret.formBuildDesign().addControl(FormControlType::String, 'Customer');
    customerCtrl.extendedDataType(extendedTypeNum(custAccount));
    customerCtrl.text(_custAccount);
    return ret;
}

3.getFromDialog
public boolean getFromDialog()
{
    boolean ret;
    ret = super();
    _custGroupId    = custGroupCtrl.text();
    _custAccount    = customerCtrl.valueStr();
    return ret;
}
4.pack
public container pack()
{
    return [#CurrentVersion,#CurrentList];
}
5.unpack
public boolean unpack(container _packedClass)
{
    Version     version = RunBase::getVersion(_packedClass);
    boolean     ret;
;
    switch (version)
    {
        case #CurrentVersion:
            [version, #CurrentList] = _packedClass;
            ret                     = true;
            break;
        default:
            ret = false;
    }
    return ret;
}
6.dialogPostRun
public void dialogPostRun(DialogRunbase dialog)
{
;
    super(dialog);
    dialog.dialogForm().formRun().controlMethodOverload(true);
    dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    custGroupCtrl   = dialog.dialogForm().formRun().design().controlName('CustGroup');
    customerCtrl    = dialog.dialogForm().formRun().design().controlName('Customer');
}
7.validate
public boolean Customer_validate()
{
;
    info(funcName());
    return true;
// validation code goes here
}

//ote: The format of the event method name is as follows: fld<ID>_1_<event name>
8.lookup
void Customer_lookup()
{
    Query                   q          = new Query();
    queryBuildRange         qbr;
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tableNum(custTable), customerCtrl);
;
    //info(funcName());
    sysTableLookup.addLookupField(fieldNum(custTable, accountNum));
    sysTableLookup.addLookupField(fieldNum(custTable, name));
    qbr = q.addDataSource(tableNum(custTable)).addRange(fieldNum(CustTable, CustGroup));
    qbr.value(custGroupCtrl.text());
    sysTableLookup.parmQuery(q);
    sysTableLookup.performFormLookup();
}
9.modified
//We can add all the other methods  as follows
public void Customer_modified()
{
;
    info(funcName());
  // modify code goes here
}

//ote: The format of the event method name is as follows: fld<ID>_1_<event name>
10.run
public void run()
{
;
    info(strfmt("customer group id : %1 ; customer account : %2",_custGroupId,_custAccount));
}
11.main
static void main(Args _args)
{
    THK_DialogSelectiveLookup test1 = new THK_DialogSelectiveLookup();
;
    if (test1.prompt())
    {
        test1.run();
    }
}

2012年4月28日星期六

How to Overriding method for a control in dialog (RunBase framework)

Scenario:
Can we have an overridden method in a dialog class. I can not use form as a dialog. I have to add a method in the dialog class. Like modified method of an EDT.

Answer:Well it can be done. First you have to add a method dialogPostRun

public void dialogPostRun(DialogRunbase dialog)
{
;
dialog.dialogForm().formRun().controlMethodOverload(true);
dialog.dialogForm().formRun().controlMethodOverloadObject(this);
dialog.formRun().controlMethodOverload(true);
dialog.formRun().controlMethodOverloadObject(this);
super(dialog);
}

This method actually allows the dialog form to override control method at runtime. Now we need the name of the control at runtine that needs the overriden method. You can get that using

print dialogCustId.name();
pause;

where dialogCustId is the EDT. let say the name returned at runtime is Fld3_1.


Now if you have to override lookup method of the EDT you can write the method like this

void Fld3_1_lookup()
{
//override lookup method here
}

If you need to override modified method

boolean Fld3_1_modified()
{
}

.
The modified method can also be accessed by overriding

public void dialogSelectCtrl()
{
}

in the runbase class. Just call

dialog.allowUpdateOnSelectCtrl(true);

in the dialog method.

You can also create a dialog form and pass it as the parameter in the dialog method of runbase class. you can find an example in tutorial_runbase class and form.

from : http://msdax.blogspot.com/2007/08/overriding-method-for-control-in-dialog.html

2012年4月24日星期二

How to export license keys that are already loaded in your system

Every now and then, there is a need to export license keys from a system. I needed to get into the VAR layer to modify code in a Microsoft VPC, but as we all know, Contoso license keys don't come with the BUS/CUS/VAR access codes. So I did what any developer would do:

  • Write a job to export the Contoso license key file
  • Import my company's partner license key file
    • DO NOT SYNC when it asks
  • Jump in the VAR layer using our layer access code to make my changes real quick
  • Import back the Contoso license key file I exported from my job and SYNC

Disclaimer (ripped from MS)
All code used below is meant for illustration purposes only and is not intended for use in production. The following disclaimer applies to all code used in this blog:

THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OR WITHOUT MODIFICATION, IS HEREBY PERMITTED.


Here is said job, enjoy!

static void OutputLicenseToText(Args _args)
{
    #define.licenseVersion(2)
    #define.KeywordLen(20)
    #define.keywordLicense('License')
    #define.keywordProperties('Properties')
    #define.keywordCodes('Codes')
    #define.keywordCodeLine('CodeLine')
    #define.keywordDate('Date')
    #define.keywordSerial('Serial')
    #define.keywordValue('Value')
    #define.blank('')
    #define.space1(' ')
    #define.space2('  ')
    #define.space3('   ')
    #define.spaceHash(' #')
    #define.OutputFilename(@'C:\OutputLicenseKeys.txt')

    #define.keywordInfo(1)
    #define.keywordWarning(2)

    SysConfig           sysConfig;
    SysLicenseCodeSort  sysLicenseCodeSort;
    container           fileOut;
    int                 i;
    System.IO.StreamWriter  sw;
    InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
    ;

    fileOut += "LicenseVersion "    + strfmt("%1", #licenseVersion);
    fileOut += #blank;
    fileOut += #keywordLicense      + #spaceHash + xSysConfig::find(ConfigType::LicenseName,0).Value;
    fileOut += #blank;
    fileOut += #space1  + #keywordProperties;
    fileOut += #space2  + "Name"            + #spaceHash    + xSysConfig::find(ConfigType::LicenseName,0).Value;
    fileOut += #space2  + #keywordSerial    + #spaceHash    + xSysConfig::find(ConfigType::SerialNo,0).Value;
    fileOut += #space2  + #keywordDate      + #spaceHash    + xSysConfig::find(ConfigType::LicenseName,1).Value;
    fileOut += #space1  + "EndProperties";
    fileOut += #blank;
    fileOut += #space1  + #keywordCodes;

    // Build CodeLines
    while select sysConfig
        where sysConfig.configType  == ConfigType::AccessCodes   &&
              sysConfig.value       != #blank
        join sysLicenseCodeSort
        order by SortIdx
        where sysLicenseCodeSort.Id == sysConfig.id
    {
        fileOut += #space2  + #keywordCodeLine  + #spaceHash    + int2str(sysConfig.id + 1);
        fileOut += #space3  + #keywordValue     + #spaceHash    + sysConfig.value;
        fileOut += #space2  + "EndCodeLine";
        fileOut += #blank;
    }

    fileOut += #blank;
    fileOut += #space2  + "EndCodes";
    fileOut += #space1  + "EndLicense";

    // Begin file output
    perm.assert();

    sw = new System.IO.StreamWriter(#OutputFilename);

    for (i=1; i<=conLen(fileOut); i++)
    {
        sw.WriteLine(conPeek(fileOut, i));
    }

    sw.Flush();
    sw.Close();
    sw.Dispose();

    CodeAccessPermission::revertAssert();

    info("License successfully output to " + #OutputFilename);
}

About some of interview questions in microsoft dynamics AX

1. Can we 2-tier / 3 tier thick deployment of Dynamics AX is possible?

ANS: No, Only Option available is 3 tier configurations with a thin client.

2. What type of changes are there in Axapta3.0 and AX4.0 related to recid?

ANS: Axapta3.0 recid is 32 bit. Ax4.0 recid is 64 bit.

3. Can we specify the type of operation a user can perform on table depending upon user’s permission in Dynamics Ax 4.0?

ANS: Yes using AOSAuthorization table property.

4. What is unit testing framework in Dynamics Ax 4.0?

ANS: Microsoft Dynamics AX now has an integrated Unit Test Framework built into the MorphX development environment. Unit tests are made as individual test cases. Each test can include a number of tests in the form of assertions. Test cases can be contained within test suite classes or as part of a project in MorphX. Testing can be done from the Unit Test toolbar from which individual test cases, test suites, or test projects can be executed. Test results can be viewed from the Unit Test toolbar that indicates the test passed or failed state, per case and test, and can even include code coverage measures for the classes and methods that are tested.

Tools à Development Tools à Unit Test

5. What is the difference in Cross Reference of Ax 3.0 and Ax 4.0?

ANS: Cross-references to other Microsoft Dynamics AX objects are now name-based and no longer ID-based. If you rename an object, you need to update all the references to it.

6. What is the difference in Layers of Ax 3.0 and Ax 4.0?

ANS: The GLS layer has now been merged into the SYS layer. A new SE layer has been introduced. The IDs for the SYS layer are now 1-14000. The IDs for the SE layer are 14001-16000.

7. What is optimistic concurrency control? And how you can enable it for a table in Ax 4.0?

ANS:

· The optimistic concurrency control is enabled for a table by setting the OccEnabled property on a table or calling the DictTable.occEnabled method.

· When this mode is enabled, data is not locked from future modification when it is fetched from the database. Data is locked only when the actual update is performed.

8. What type of communication is there between Client and Server in Ax4.0?

ANS: RPC where as in 3.0 it is socket programming.

9. What type of changes are there in Axapta3.0 and AX4.0 related to recid?

ANS: Axapta3.0 recid is 32 bit. Ax4.0 recid is 64 bit.

10. What we need to consider at the time of installation when upgrading?

ANS: check box Start the AOS Windows service as part of installation should be unchecked.

11. Can I have 2-tier installation of AX?

ANS: No. Ax has only 3-tier installation whereas Axapta3.0 supports both 2-tier and 3-tier.

12. What type of communication is there between Client and Server in Ax4.0?

ANS: RPC where as in 3.0 it is socket programming.



13. What type of changes are there in Axapta3.0 and AX4.0 related to recid?

ANS: Axapta3.0 recid is 32 bit. Ax4.0 recid is 64 bit.

14. What are the 4 types of files we need to copy to the standard folder?

ANS: *.aod, *.ahd, *.ald, *.add, *.khd

15. Which file we delete from standard folder?

ANS: axapd.aoi file( Index file).

16. What is Enterprise portal?

ANS: Web enable part of Axapta is called enterprise portal.

17. What business connector enterprise portal uses to connect with SharePoint?

ANS: .Net business connector in AX4.0 COM business connector in 3.0.

18. What type of objects can I expose to enterprise portal?

ANS: Webforms, Webreports, AXreports, Classes. But not AXForms.

19. What are the two types of WebMenuItems in AX?

ANS: URLs and Actions.

20. What type of WebmenuItem we use for WebReports and WebForms?

ANS: URL type.

21. What are two types of WebContentItems in AX?

ANS: Display and Output.

22. Can we see the AX form in EP?

ANS: No. we can’t see the AX form in EP.

23. How many default templates are available for enterprise portal in SharePoint template picker?

ANS: 2 Templates.

· Microsoft Dynamics Enterprise Portal

· Microsoft Dynamics Public

24. Business connector proxy must be a member of which user groups in AD?

ANS: IIS_WPG, SPS_WPG

25. Action type WebmenuItem is used to refer what type of object in AX?

ANS: Classes and Jobs.

26. Output type webContent is used to refer what type of objects in AX?

ANS: Web reports and reports.

27. Display type webContent is used to refer what type of objects in AX?

ANS: Web Forms only.

28. Where can I register the site as EP site?

ANS: In administration->setup->Internet->Enterprise portal->Websites->register website button.





29. What type of weblet we use to display the Axreport or Webreport in EP?

ANS: WebReportweblet.

30. What type of weblet we use to display the Webforms in EP?

ANS: WebFormWeblet.

31. Name few of the Dynamics Ax Weblets.

ANS: WebReportweblet, WebFormWeblet, WebImageWeblet, PageTitleWeblet, WebMenuBoxWeblet, WebMenuWeblet.

32. Where can we find the AX weblets in sharepoint?

ANS: In virtual server gallery.

33. Why we use virtual companies?

ANS: Virtual company accounts contain data in certain tables that are shared by any number of company accounts. This allows users to post information in one company that will be available to another company.

34. To enable the Debugging of X++ what should we do?

ANS: Set the debug mode to “When break point” in Development tab in tools-> options.

Check “Enable breakpoints to debug X++ code running on this server” on the server configuration utility to debug the server code.

35. Can we debug the Business connector code running on the server?

ANS: Yes. By selecting the check box “Enable User break points to debug code running on the Business connector”.

36. What type of relationship we can define for an extended Data Type (Multiple ANSwer)

ANS: Single Field Relationship, Conditions on a relationship

37. While implementing ax when it is advisable to setup the virtual companies?

ANS: If you would like to use virtual companies at some time in the future, it is best to set up the virtual companies from the beginning of the implementation of Microsoft Dynamics AX. This avoids problems with combining records into a shared table at some time in the future.

38. Before you can create or modify a virtual company account what must be established?

ANS:

· The application object server that the administrator is connected to must be the only one running. All other application object servers must be shut down.

· Only the administrator who is creating the virtual company account can be connected; only one active client connection is allowed.

· After you create or modify a virtual company account, you must restart the Microsoft Dynamics AX client in order to update the client with the new virtual company account information.

39. How u can check that for a particular SQL call RLS is applied or not?

ANS: Using Database trace. Database trace should be activated for this. For RLS applied statements it will show like this salesLine.select () (RLS)





40. What is the difference between the Client kernel and Business connector kernel?

ANS:

· The Session Manager in the client kernel manages only a single instance--in the Business Connector kernel, it manages multiple instances.

· The client kernel includes forms security, while the Business Connector kernel does not.

41. What Type of cache you will apply for most static data

ANS: Found

42. How can we cache a display method of a table?

ANS: By Using CacheAddMethod

43. When there are common methods across tables, which will be the best option to create?

ANS: Create a map and add those methods and corresponding tables

44. How can we restrict a class to be further extended?

ANS: using Final Keyword for ex: public final class <ClassName>

45. In Axapta can we use tables as classes?

ANS: Yes

46. If yes Then Can we extend the table as similar to class? If yes then how it is possible and if no then why?

ANS: No, Tables are by default Final.

47. What all are methods modifiers?

ANS: abstract, client, display, edit, final, public, private, protected, server, static.

48. I want to put final modifier to new and finalize methods? How can I do this where I need to right this keyword in method?

ANS: You cannot use Final modifiers for the New and Finalize methods.

49. What are optional parameters?

ANS: It is possible to initialize parameters in the method declaration. This makes the parameter an optional parameter. If no value is supplied in the method call, the default value is used.

50. What are local functions?

ANS: With X++, you can embed a function inside a method to create a local function (or local method). The local functions that you can create in X++ are only visible within the scope where they are defined.

51. How u can get the count of methods in a class?

ANS: Using DictClass methods: staticMethodCount and objectMethodCount

52. Which class will be used for ODBC connection?

ANS: ODBCConnection

53. Which are classes are used for data import export?

ANS: SysDataImport and SysDataExport



54. Which is the base class for these two classes above mentioned?

ANS: SysDataImportBase and SysDataExportBase.

55. Which class will be used to get the object names, security key names / count, configuration key name/ count etc.?

ANS: Dictionary

56. Which is the class used for creating / opening files?

ANS: IO

57. How can we get the no of table available in Ax through code?

ANS: Using Dictionary class object tablecnt method.

58. Which class will be used to get the online users info?

ANS: SysUsersOnline

59. Which is the mandatory parameter needs to be passed while creating the ODBC connection class object?

ANS: LoginProperty class object.

60. Which all classes will be used to create a com object for excel application?

ANS: SysExcel, SysExcelApplication, SysExcelApplication_2000, SysExcelApplication_2007, SysExcelApplication_XP.

Note: There are related classes for opening the workbooks, worksheets, range, cells. For Ex:SysExcelCell, SysExcelCell_2000, SysExcelCell_XP, SysExcelCell_2007.

61. How can we get the client computer name through code?

ANS: Class xSession, Method: clientComputerName()

62. Do you know about List class in Dynamics Ax? Why it is used?

ANS: Lists are structures that can contain values of any X++ type. All the values in the list must be of the same type.

63. Which function is used to get current user name in Ax?

ANS: Curusrid();

64. Which function is used to change the company through code?

ANS: ChangeCompany(‘companyName’);

65. From which table u can get the user permissions stored in Ax?

ANS: AccessRightList table.

66. What is the use of VirtualDataAreaList table?

ANS: This table stores the list of virtual companies available in Dynamics Ax.

67. What all are aggregate functions available in select statement of X++?

ANS: sum | avg | minof | maxof | count

Options = [(order by | group by) FieldIdentifier [ asc | desc ]

68. What is the use of update method?

ANS: Updates the current record with the contents of the buffer.





69. When one should use doUpdate?

ANS: The doUpdate method should be used when the update method on the table is to be bypassed.

70. What is the difference between X++ and SQL sort command in select statement?

ANS: X++ does not allow group by and order by clauses in the same select statement. This means that explicit sorting is not possible. SQL does allow group by and order by clauses to be in the same statement.

71. What should we use to increase performance while inserting, updating or deleting records from a table?

ANS:

· RecordSortedList: Allows you to insert multiple records in one database trip. Use the RecordSortedList construct when you want a subset of data from a particular table, and when you want it sorted in an order that does not currently exist as an index.

· RecordInsertList: Allows you to insert multiple records in one database trip. Use the RecordInsertList construct when you do not need to sort the data.

· insert_recordset: Allows you to copy multiple records from one or more tables directly into another table on a single database trip.

· update_recordset: Allows you to update multiple rows in a table on a single database trip.

· delete_from Allows you to delete multiple records from the database on a single database trip.

72. Do forms support Inheritance?

ANS: No

73. What is must to be declared for a control to get accessed anywhere in the form?

ANS: In the control properties set the Auto declaration property to yes.

74. What should we do if we need last record to be active when a form is opened?

ANS: In properties of datasource table set the StartPosition property as last.

75. What are the different link types available?

ANS:

· Active

· Delayed

· Passive

· InnerJoin

· OuterJoin

· ExistsJoin

· NotExistsJoin





76. What are the three basic nodes found in Forms Node?

ANS:

· Methods

· Data Sources

· The Data source defines the interface between the form and the database.

· Design

· The design of the form defines the interface between the form and the user and controls the layout and presentation of the data.

77. What for Formrun Kernel class and FormDataSource Kernel Class are used?

ANS:

· Formrun Kernel class is used to control the Startup and Shutdown of the form.

· FormDataSource Kernel Class contains the methods which are used for Displaying, Validating and Updating data in forms.

· The objects for each data source and data fields defined are inherited form which kernel class?

· (Data Source)FormDataSource which has methods related to displaying, validating, and updating data.

· (Data Field)FormDataObject which has methods related to field specific navigation (filter, lookup, jump to main table etc.), validating and modifying the field.

78. What properties are to be used and set in a form for automatically creating a new record in it?

ANS:

· Set the InsertIfEmpty Property to yes if the forms do not find any data

· Set the InsertAtEnd Property to yes if the user browses past the last record in the data source

· (Note: If the user browses past the last record in the data source)

79. Different Properties of a field.

ANS:

· Allow Edit: This property specifies whether the field can be changed. This property can't remove a restriction imposed by the table field, security settings, or the data source.

· Enabled: The enabled property specifies whether the user can access the control. If the field is disabled it will be grayed and the used can not give focus to the control.

· Visible: This property can be used to remove a field from the user interface. The same property exists on the database field and should be specified here if the option should apply system wide.

· Allow Edit: This property specified whether the field can be added to the design by the user. Because the default value is restricted, the default behavior of forms is set so that extra information cannot be added to the form.

In order to add a field to a design, two prerequisites must be met.

· The AllowAdd property on the datasource field must allow the field to be added.

· The container where the field is to be added must allow full user setup

Mandatory: This option determines if it is required to fill in data in this field. The same property exists on the database field and should be specified here if the option should apply system wide.

80. Which is the best practice followed for placing code?

ANS: To program system wide logic which is tight related to a record, we should place the logic in object methods on the table. The table which inherits from the kernel class xRecord has many events we can override and supplement with our logic.

If we are to put the X++ code in the form, try to avoid programming on the design and put our logic on the data source. Many events on the design are very dependant on exactly how the user is navigating the form. The programming on the controls does not take the user possibility to modify the contents of the form into account.

81. What does FormRun.Init method do?

ANS: This method initializes the form and its objects and is the first event we can override in connection with the start up of the form.

82. What is the importance of super call method in FormRun.Init?

ANS: Never remove the super () call from this method, as this removes the initialization of all the objects.

83. How to do manual initializations in FormRun.Init?

ANS: If you want to make some manual initializations this is typically placed in this method. This could include the following tasks:

· Verification of the contents of the args-object received

· Initialization of supporting classes

· Dynamically changes to the design

84. What is FormRun.Close method used for?

ANS: This method shuts down the form. If we have some cleanup in connection with finishing the execution of the form, this will be the place.

85. What is FormDataSource.Init method used for?

ANS:

· This method initializes the data source and is called from the super () of FormRun.Init (). The method will only be called once when the form is opened.

· The main task for this method is to initialize the query used for fetching data.

· If we want to modify or replace the query automatically created by the form, this should be done after the super () call of this method.

86. FormDataSource.InitValue Method?

ANS:

· This method is used to initialize a new record with default values. The super () of this method calls the corresponding method on the underlying table, which in turn invokes the record template functionality.

· If we have some initialization which should apply system wide, you should place the code on the table.

87. FormDataSource.Active Method?

ANS:

· This event is called when a new record becomes active in the data source and is typically overridden to change properties which depend on the contents of the current record:

o Modify access rights to the data source

o Modify access rights to the fields

o Enable/Disable buttons

88. Where is the specification of fields stored in report?

ANS: AutoDesignSpecs

89. How many generated designs we can have in a report design?

ANS: 1

90. What is the sequence of events while a report is generated?

ANS: Init, Run, Prompt, Fetch, Print

91. If AutoHeader property of the query is set to Yes, where will this get reflected?

ANS: Report

92. Through overriding of which method of report we can restrict the user to see only certain records which are not possible through the range method?

ANS: Fetch

93. Through overriding of which method we can hide the columns or parts of report?

ANS: Execute Section

94. If the design is similar for more than one report what is the best solution in developing such reports?

ANS: Use Report Templates.

95. What are query criteria operators?

ANS: = =,!=, >, <, ..(Range)

96. Name few X++ classes/Coreclasses related to Queries?

ANS: Query, QueryRun, QueryBuildRange, QueryBuildDataSource, QueryBuildLink.

97. How many sorting fields we can add to a query?

ANS: we can add many. But adding many will slow down the query performance.

1. Can we add index as a sort filed?

ANS: Yes. Only one index we can add.

2. Which operator we can use to give the range between two values?

ANS: the ..(two dots)operator.

3. How can I see the result of the Query written in Queries node in AOT?

ANS: We need to write a job to see the result of a query.

4. How do we use expressions in query ranges?

ANS: Using the strfmt() function

EX write a query to get all the customers from the custtable where custgroup belogs to 50 and currency is “CAD”.

· qr1=qbr1.addRange(fieldNum(custtable,dataareaid));

· qr1.value(strfmt('((CustGroup=="%1") && (currency=="%2"))',QueryValue("50"),QueryValue("CAD")));

5. When using the Enum in the Range filed of the Query, What should be used? Enum value or Enum ID?

ANS: EnumID should be used. String value can’t be used.

6. What does the fetch mode on Queries means?

ANS: Determines whether the data sources should be related through a 1:1 relation or a 1:n relation.

7. What does the Autosum property on Query on reports specifies?

ANS: Determines if a group total is printed when the value in this field changes.

8. What are the best practices for creating the variables in the class:

ANS:

· Do not create object member variables that do not hold the state of the object. Pass these values as arguments.

· Do not create an object member only because a variable of that type and name is needed in more than one method in the object. Create the variable in each place it is needed.

9. What are the best practices for class wide constants?

ANS: If you have to declare some constants that will be used in more than one method in the class or its subclasses, declare these constants in the class declaration (by using the #define technique).

10. What is the use of init method of a class and what are the best practices checks for it?

ANS:

Yes if you need to carry out any special initialization tasks after class instantiation and after the setting of class variables by using accessor methods, such logic should be placed in a private method called init.

Init methods should be protected, and should have a void return type, or else a Boolean return type if initialization can go wrong, so that an error can be thrown.

11. What is the best practices check for destructors?

ANS:

· The finalize method should not normally be used (leave it empty, do not call it). X++ objects are destructed when there are no more references to them

· The finalize method will destruct an object when it is called, regardless of how many references there are to that object.

· There are no implicit calls to finalize; it is not called automatically when the object is destructed. If you define a finalize method, you must have explicit calls to it.

12. What is the use of client and server modifiers for a method?

ANS:

· These qualifiers are used for Application Object Server (AOS) tuning, where the task is to minimize the traffic between the client and the server. They are relevant only for table methods and static class methods, because other methods (class instance methods) run where their class is instantiated.

· If a method is running on the server and only makes a single call to the client, it is okay to keep it on the server. If a method makes more than one call, move it to the client and then return it.

· If a method is running on the client and only makes a single call to the server, it is okay to keep it on the client. If a method makes more than one call, move it to the server and then return it.





13. When it is appropriate to make a method static?

ANS:

· It does not use the instance member variables or fields that are defined for the class.

· It is not going to be overridden.

· It runs better on a different tier than the object itself.

· It is related to the class or table, but it does not have its origin in a single object (instance).

14. What is the use of abstract modifier in a method?

ANS: Use the abstract qualifier when a method has to be implemented in a subclass. Even if it has no effect, it serves as documentation.

15. What is an index?

ANS: An index is a table-specific database structure that speeds the retrieval of rows from the table. Indexes are used to improve the performance of data retrieval and sometimes to ensure the existence of unique records.

16. How one can create a unique index?

ANS: By setting up the “allow duplicate property” to No.

17. Can we disable an index?

ANS: Yes

18. Which element maintains database consistency when a record is deleted:

ANS: Delete Action

19. Specify the type of delete actions?

ANS: Cascade, restricted, Cascade + restricted

20. What is system index?

ANS: Microsoft Dynamics AX requires a unique index on each table so if there are no indexes on a table or all the indexes are disabled, a system index is automatically created. The system index is created on the RecId and DataAreaId fields if the DataAreaId field exists. Otherwise the system index is created on the RecId field. You can see system indexes in the database but they aren't visible in the AOT.

21. What will happen if one add a delete action to a table and use delete_from statement?

ANS: database performance will be slow

22. What is the use of configuration key in Ax?

ANS: Configuration keys allow administrators to enable or disable features in the application for all users. Disabling features helps to minimize the attack surface against potential attacks.

23. Where one can setup the configuration key?

ANS: Configuration keys are applied by setting the Configuration Key property on these objects in the Application Object Tree (AOT).

24. Can we apply a configuration key on table field and report’s control?

ANS: Yes

25. Can we create a new configuration key?

ANS: Yes

26. What is the use of security key in Ax?

ANS: Security keys allow administrators to set security on a user group level. Minimizing access on a user group level helps to reduce the attack surface against potential attacks.

27. What are all the main reasons to apply user-level security?

ANS:

· Allow users to do only their designated tasks.

· Protect sensitive data in the database.

· Prevent users from inadvertently breaking an application by changing code or objects on which the application depends.

28. What is use of AOSAuthorization table property?

ANS: The AOSAuthorization table property enables you to specify which data access operations must undergo user permission checking.

29. What are fundamental data access operations for AOS authorization table property? And how one can use it?

ANS: The four fundamental data access operations are create, read, update, and delete. These operations are represented in combinations by the following AOSAuthorization enumeration values:

· None

· CreateDelete

· UpdateDelete

· CreateUpdateDelete

· CreateReadUpdateDelete

No permission checking is done when the AOSAuthorization property is set to none.

Suppose AOSAuthorization is set to CreateDelete on a given table. In this case, create and delete operations would be allowed to execute only if the Application Object Server (AOS) can confirm that the user has the appropriate permissions.

30. What is default value of AOSAuthorization table property when a new table will be created?

ANS: When a new table is created, its AOSAuthorization value is set to none.

31. Will AOSAuthorization property be used for views?

ANS: Yes

32. What is code access security?

ANS:

· Code Access Security (CAS) helps protect APIs that have potential security risks when the APIs are running on the server.

· CAS-enabled APIs called on the server require the use of a permission class—one of the classes derived from CodeAccessPermission.

33. How data authorization in Microsoft Dynamics Ax is performed?

ANS:

· Data authorization in Microsoft Dynamics AX is performed in three ways:

· Implicit authorization

· Checks done by setting security properties on Application Object Tree (AOT) objects

· Checks done in X++