Interview Questions

Thursday, August 26, 2021

System does not support setup 'continuous' of number sequence ####.

 Hi Friend,

Sometime we got the requirement that through code we need to create next number sequence value. But when we will write the code then during execution we got error message as = "System does not support setup 'continuous' of number sequence ####."


For solving this issue please add number sequence line between "TTS Begin" and "TTS Commit".

You need to put a ttsbegin/ttscommit statement around your number sequence generation code if you want to use a continuous number sequence. Continuous number sequences allow you to release unused numbers back to the pool of number sequences to use. Decide first if you want/need a continuous number sequence and then make it work. Unchecking the 'continuous' number sequence checkbox will work, but it may not be the final solution that you need.

 

Tuesday, August 24, 2021

How to make any button as by default selected on dialog created by X++

Hi Friends,

Sometime we got the requirement the we need to make "Cancel" button as by default selected on dialog created through X++;

So below function will help you to make "Cancel" button as default button on dialog.


Code: "dialog.defaultButton(DialogDefaultButton::Cancel);"



Tuesday, July 14, 2020

How to compile ax application objects through command prompt

Hi Guys,

If we need to save our time from compilation, we can follow below steps:

1- Open command prompt as administrator
2- Type below command
Command : axbuild.exe xppcompileall /s=01(instancenumber)

instance number = AOS number

normally, this type of compilation will complete in 20-30 mins. Depends on the cors used in process.

Monday, July 13, 2020

Cannot start AOS / Error: Cannot create another system semaphore.

Hi Friends,

Some time we found that after restoration of DB, one error popup during AOS start:
"Cannot create another system semaphore".

For this issue please find below solutions:
1- Open "SQL server management studio" as admin then select your master db and create below query-
update SQLSystemVariables
set value = '4'
where parm = 'SYSTIMEZONESVERSION'

After creation execute the query.
It worked for me.

2- check the user permission through which you are trying to start the AOS.

Thursday, March 22, 2018

How to use ternary operator in ax 2012

Hi All,

As we all know that we in some scenarios we need to use Ternary operator for reducing code lines. In a single line we can execute multiple cases.
For achieving this, please go through with below code.

Sample Job for ternary operator:

static void GOD_TernaryOperatorEx(Args _args)
{
    int a, b, c;
    ;

    a = 9;
    c = 8; 
         
    b = (a < 10 ) ? info ("Yes") : info ("No");
   In above line of code we are executing single condition or in other word we can say "If" Condition.
   In this condition we are just testing that "A is greater than 10 or not. If it is, then it will generate       info with "Yes"".

    Or

    b = (a < 10 ) ? ((a < c) ? info ("Yes") : info ("Nope")) : info ("No");
   In above line of code we are executing multiple conditions or in other word we can say "If and else if" Condition.
   In this condition we are testing that "A is greater than 10 or not. If it is not then it will print No, else it will again check that A is greater than "C" or not. If yes then it will print Yes else it will show Nope.
}

Tuesday, March 20, 2018

Use Temporary Table as form datasource in ax 2012

Hi All,

In many scenarios we need to use temporary table as form data source. So below steps are used to achieve this target.

Step 1 - Create a temporary table and make "Table Type" property as "TempDB"
Step 2 - Create a class to fetch or generate the data and insert into temporary table.
Step 3 - Create a method in class for executing your code.

For ex- 
public TempTableTmp  GenerateTempTable()
{
    TempTableTmp       tempTable;
    ;

    Write your logic and insert into temporary table then write below line:
    return tempTable;
}

Step 4 - Create a form and used temporary table created in step 1 as data source.

Step 5 - Override init method at form data source level.

Step 6 - In this method we need to instatiate the class which we have developed at step 2

For Ex - 
public void init()
{
TempTableClass temptableclass = new TempTableClass();

super();

tempTable = temptableclass.GenerateTempTable();

TempTableTmp.linkPhysicalTableInstance(tempTable);
//In above line if you will not use "LinkPhysicalTableInstance" method then you will not get the data on form.


Step 7 - Create a display type menu-item and place at your desired place.

It will solve your issue.

Thursday, December 21, 2017

How to create lookup method in ax 2012....

Hi Guys,

Scenario:
1- If you want to show any lookup on form's field
2- If master table field lookup you want to show in parent table 2 fields.
For ex-
You have Parent table "DiscountMaster" and field "MasterID"
and Child table "Discount Details" and fields "Discount Master ID", "Discount Code"

Now, if you want to show the lookup in fields "Discount Master ID", "Discount Code"
then normal solution is "you need to create relation with parent table" but whenever you will go to create normal relation between 2 fields of child table with 1 field of parent table then in the second record of relation will not show the complete lookup value. It will show only first field selected value in lookup. Then in this case you need to override lookup method:

For that please use below code;

public void lookup()
{
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;

    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(DiscountMaster), this);

    sysTableLookup.addLookupField(fieldNum(DiscountMaster, MasterID));

    queryBuildDataSource = query.addDataSource(tableNum(DiscountMaster));
 

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();

    //super();
}

it will solve your issue.

Note: Don't forget to remove relation with second field.