Wednesday, December 14, 2011

Sometimes AX doesn't work as expected even if changes has been made to a code. Here are some suggestions

Compile

Compile and recompile.

License

While coding in a class, make sure that you have a x++ license, otherwise every changes made to a class will not be used.

Close the debugger
Sometimes, when the debugger is active, AX will keep executing ‘old’ code. Close the debugger to make sure the latest code is executing.

Synchronize data dictionary

Open the specific tables and synchronize or if everything else fails, just synchronize the whole AOT.

Restart AX

Simple as that, close the AX client and start it again.

Reset usage data
Go to options screen (AX button > Extra > Options) and click the Usage Data button. Click reset to remove this data.

Check the application event log for clues
Open the event viewer on the AOS to see if the AOS service has logged something in it. Messages here can help you a great deal. You can also check the event log on the database server or your client pc.

Delete AUC file

The application Unicode object cache file, if there is one, is located at C:\Documents and Settings\[USERNAME]\Local Settings\Application Data for xp, or C:\Users\USERNAME\AppData\Local for vista. Delete this file while the AX client is closed.

Full compile

Restart AOS

Remove .aoi file


Thursday, December 8, 2011

New Line in Report

To add a line break in Dynamics AX report, just add the character '\n' to a String and make sure that its label's Dynamic Height in Dynamics AX report is set to "Yes"

Monday, December 5, 2011

Terbilang Function in Dynamics Ax in Indonesian

static TempStr numeralsToTxt_Indo(Real _num)
{
int numOfPennies = frac(_num)*100 mod 100;
int test = round(_num,0);

int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, millions, billions;

int temp;
str 200 returntxt;

int checkPower(int _test, int _power)
{
int numOfPower;

if (_test >= _power)
{
numOfPower = _test DIV _power;
if (numOfPower >= 100)
{
temp = numOfPower DIV 100;
returntxt = returntxt + ' ' + ones[temp] + ' ' + hundreds;
numOfPower = numOfPower MOD 100;
}
if (numOfPower >= 20)
{
temp = numOfPower DIV 10;
returntxt = returntxt + ' ' + tenths[temp];
numOfPower = numOfPower MOD 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt + ' ' + ones[numOfPower];
numOfPower = numOfPower MOD 10;
}
switch(_power)
{
case 1000000000 :
{
returntxt = returntxt + ' ' + billions;
_test = _test MOD 1000000000;
break;
}
case 1000000 :
{
returntxt = returntxt + ' ' + millions;
_test = _test MOD 1000000;
break;
}
case 1000 :
{
returntxt = returntxt + ' ' + thousands;
_test = _test MOD 1000;
break;
}
case 100 :
{
returntxt = returntxt + ' ' + hundreds;
_test = _test MOD 100;
break;
}
}
}
return _test;
}



ones[1] = "Satu";
ones[2] = "Dua";
ones[3] = "Tiga";
ones[4] = "Empat";
ones[5] = "Lima";
ones[6] = "Enam";
ones[7] = "Tujuh";
ones[8] = "Delapan";
ones[9] = "Sembilan";
ones[10] = "Sepuluh";
ones[11] = "Sebelas";
ones[12] = "Dua Belas";
ones[13] = "Tiga Belas";
ones[14] = "Empat Belas";
ones[15] = "Lima Belas";
ones[16] = "Enam Belas";
ones[17] = "Tujuh Belas";
ones[18] = "Delapan Belas";
ones[19] = "Sembilan Belas";

tenths[1] = 'Not used';
tenths[2] = "Dua Puluh";
tenths[3] = "Tiga Puluh";
tenths[4] = "Empat Puluh";
tenths[5] = "Lima Puluh";
tenths[6] = "Enam Puluh";
tenths[7] = "Tujuh Puluh";
tenths[8] = "Delapan Puluh";
tenths[9] = "Sembilan Puluh";

hundreds = "Ratus";
thousands = "Ribu";
millions = "Juta";
billions = "Miliar";


test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
test = checkPower(test, 1000);
test = checkPower(test, 100);

if (test >= 20)
{
numOfTenths = test DIV 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths MOD 10;
test = test MOD 10;
}
if (test >= 1)
{
numOfTenths = test;
returntxt = returntxt + ' ' + ones[numOfTenths];
}

if (numOfPennies)
{
//returntxt = '***' + returntxt + ' ' + "@SYS5534" + ' ' + num2str(numOfPennies,0,0,0,0) + '/100';
//returntxt = returntxt + ' ' + num2str(numOfPennies,0,0,0,0) + '/100';
returntxt = returntxt + numeralstotxt_indo(numofpennies) + ' Sen';


}

if (strscan(strltrim(returntxt),"Satu Ribu",1,15)==1)
{
returntxt = strReplace(returntxt, "Satu Ribu", "Seribu");
}

returntxt = strReplace(returntxt, "Juta Satu Ribu", "Juta Seribu");
returntxt = strReplace(returntxt, "Satu Ratus", "Seratus");
return returntxt;
}

Monday, November 21, 2011

Executing application from Dynamics AX

Simply use :

WINAPI::shellExecute("iexplore.exe","yahoo.com");

System does not support setup 'continuous' of number sequence Error

System does not support setup 'continuous' of number sequence error :


This error will be thrown if whenever NumberSeq::newGetNum function is called without an encapsulating transaction. To fix this error simply put number sequence related function within a ttsbegin and a ttscommit;


Thursday, October 27, 2011

Connecting Atlas XL to Dynamics AX Server

To setup a new connection from Atlas XL to Dynamics AX server, you have to run Atlas Server Service Configuration.
Screenshot of Atlas XL Server Service Configuration

To setup a new connection, you will need to configure a few things :
  1. Specify a name for the connection that you want to add in Service Name (TESTSERVER).
  2. Specify a port number for Atlas XL to use between Atlas XL client and server service. (By default it will specified 9006, note that if you change the port number in the server service, you will need to change them in the client service).
  3. Specify a Dynamics AX service name. Which for me is DynamicsAx1 (Dynamics instance name) located on Andromeda server.
  4. Specify a port number used by Dynamics AX service.
  5. Click on Add Service and you are ready to go.

Wednesday, October 26, 2011

Setup button in Form

Usually when right clicking while running a form, there is a Setup button in the context menu. But sometimes if there isn't. In that case, for that specified user, a permission must be set.
You can set the permission by doing :
  1. Make sure that you are opening Administration tab.
  2. Click on Users and select the specified user (For this case I selected "receptionist").
  3. Click on the Permission button.
  4. Click on the Permission tab in the User Permission window.
  5. Make sure that you are viewing Security, and go to Administration -> Miscellanous and look for Form Personalization value. Make sure that it is checked and if it is not you can give it a value by changing the Access Mode.
User Permission window

Monday, October 17, 2011

Creating Go to the Main Table Form References

There's a couple ways to implement Go to the Main Table Form references.

Here's the easiest way :

1. Create an Extended Data Type and relates it to the table you're referencing.







2. Create a form based on the main table (in my case it is CITTaxPIC table).
3. Create a MenuItem references to the created form (CITTaxPIC form).
4. Set FormRef in the main table to the created MenuItem (CITTaxPIC).












5. Add a new field using the EDT to the form data source's table you want to setup Go To Main Table Form references and you're ready to go.

Note that the displayed field are the EDT and the fields, set up in TitleField1 and TitleField2 in the Main Table.

Thursday, October 13, 2011

Creating and Using Number Sequences


public server static NumberSequenceReference numRefCustomNumber()
{
return NumberSeqReference::findReference(typeId2ExtendedTypeId(typeid(CustomId)));
}

Tuesday, October 11, 2011

Classes used while Posting Picking List, Packing Slip, Purchase Order, Invoice

Used for Posting Receipts List :
- Class PurchFormLetter_ReceiptsList
- Tables : vendReceiptsListJour, vendReceiptsListTrans
Used for Posting Packing Slip :
- Class PurchFormLetter_PackingSlip
- Tables : vendPackingSlipJour, vendPackingSlipTrans
Used for Posting Purchase Order :
- Class PurchFormLetter_PurchOrder
- Tables : vendPurchOrderJour, vendPurchOrderTrans
Used for Posting Invoice :
- Class PurchFormLetter_Invoice
- Tables : vendInvoiceJour, vendInvoiceTrans

Monday, October 10, 2011

How to get the number of rows in a query

This will return the number of rows currently available in a query :

SysQuery::countTotal(SalesTable_ds.queryRun();

while to return the number of rows loaded in a query :

SalesTable_ds.numberOfRowsLoaded();

Note that SalesTable_ds is a FormDataSource.