Wednesday, 21 September 2011

Classic explorer UP button / status bar free space

If these questions brought you here, you probably need "Classic Explorer":
- Missing UP button in Windows Explorer
- Missing status bar free space in Windows Explorer

In Windows Vista, Windows 7 or Windows Server 2008 / 2008 R2, two of the useful features has been removed from Windows Explorer, they're the "UP" button and "Status bar free space".

Classic Explorer return these features to you, download and install it, the "UP" button and "Free space" will show up the next time you start up Windows Explorer.


BeforeAfter



After installation and restart Windows Explorer, if the features still doesn't shows up, you might need to enable it. Another reason would be when you're still new with it, you might have accidentally & unconciously disabled it.

Follow these steps to enable/show it:
  1. Open Internet Explorer
  2. Right click on the toolbar and click on "Classics Explorer Bar"


  3. It will prompt and ask whether you want to enable the Add-on, check the "ExplorerBHO class" and click "Enable"


If you're on server and the above doesn't seems to works for you, you might want to enable browser extention as well.
  1. Go to Control Panel > Internet Options > Advanced (tab)
  2. Check the option "Enable third-party browser extensions" and click OK

Monday, 19 September 2011

Reset Nokia E71 phone


Lost my HTC Desire last week at Copenhagen, sad case.
Was given a replacement this week - Nokia E71, felt like back to stone-age.
Will temporarily use it till Android Ice-Cream-Sandwich is released.


I found that the menu is not user friendly, for those who look for quick reset of the phone, here's the key:

  1. *#7780#
    Enter that into your phone using the keypad, then it will prompt for confirmation to reset to factory default. This only reset all the settings to default factory settings, it doesn't wipe out the data.
  2. Change to "General" profile
  3. *#7370#
    Enter that into your phone using the keypad, then it will prompt for confirmation to format the phone and wipe out the data on the phone (but not on the memory card). It will restart the phone when it is done.

In case you need the default security key/pin, it is: 12345



Friday, 9 September 2011

Swap ThinkPad Fn & Ctrl key


For those who hate the position of the Fn & Ctrl key on the new ThinkPad, follows this steps to swap them.

  • Boot up your machine
  • Press the blue ThinkVantage button
  • Press F1 into BIOS
  • Goto Config > Keyboard and Mouse > Fn and Ctrl Key Swap
  • Change it to “Enabled”
  • Hit “F10” to save and exit

Wednesday, 7 September 2011

Windows Server 2008, interact with session 0 UI (net start ui0detect)

net stop ui0detect
net start ui0detect

====================

In Windows Server 2003, you can connect to console session of the server by 'mstsc.exe /console', but this has been deprecated in Windows Server 2008. So, what happens if you have some Windows services which sometimes prompt up dialogue at the console session? If you’re new to Windows Server 2008 and coming from 2003, you might stuck for a while thinking how you can get to those dialogue, worry not, it has a built-in capability which enables you to view and to interact with the session 0 UI from your session.

“if the service that is associated with an application tries to display UI elements in session 0, a built-in capability in Windows Server 2008, Windows Server 2008 R2 and in Windows Vista enables you to view and to interact with the session 0 UI from your session”.

Let’s get straight to our scenario.

One of our client is using Dynamics AX2009, although AX2009 runs batch within AOS, but there’re certain batch job won’t works that way. Eg. A batch job which instantiate Excel file, read and write to it.
It has to be run using the legacy batch framework. We use FireDaemon to setup AX client to run as a Windows service. In Windows Server 2003, the AX client will start up at session 0, if you need to interact with this AX client, you can connect to it through 'mstsc.exe /console'. But the session 0 has been made non-interactive in Windows Server 2008 and the AX client runs in that session, so how do we connect to it when we need to look at the AX client?

This is what we do:
1. Logon to the server
2. Run this command in command prompt
    (you’ll need to start the command prompt in elevated mode – right click, Run as administrator)

    IF “Interactive Services Detection” is disabled
    (enable and start it)
   - sc config UI0Detect start= auto
   - net start ui0detect

    IF “Interactive Services Detection” is enabled/manual
    (restart it)
   - net stop ui0detect
   - net start ui0detect

What it actually do is to start the UI0Detect service and prompt the user if there's a dialogue in session 0. The prompt allow user to switch from current session into the "special desktop" of the session 0 which only has interaction with the application who trigger the dialogue.

"Interactive Services Detection", this is the "UI0Detect.exe"

Running the "net stop ui0detect" and "net start ui0detect" will prompt up a window allowing you to switch to the session 0 UI. Click on the "Show me the message"

When you're done, just click on "Return now" to return to your normal desktop

Example of the UI in session 0. In this session, you only see that application itself, there won't be any Start menu, taskbar, & etc.

More references at:








Wednesday, 31 August 2011

Open document handling (DocuView) for other datasource/table than caller

Sometimes there's requirement to open document handling from one form to shows the documents for other datasource/table.


Eg. From Purchase order form, open the document handling of the vendor (VendTable) instead of for the purchase order (PurchTable).


It can be achieved with the following 4 steps:
  1. Add the related table as datasource in the form
  2. Add a boolean global variable to 'ClassDeclaration'
  3. Overwrite the method 'docCursor'
  4. Add a button and overwrite the 'clicked' method

1. Add the related table as datasource in the form




2. Add a boolean global variable to 'ClassDeclaration'
class FormRun extends ObjectRun
{
    boolean      vendDoc;
}


3. Overwrite the method 'docCursor'
public Common docCursor()
{
    Common docCursor;
    ;


    docCursor = super();


    if(vendDoc)
        docCursor = vendTable;
    
    return docCursor;
}


4. Add a button and overwrite the 'clicked' method
void clicked()
{
    super();


    vendDoc = true;


    if (!infolog.docu().isDocuViewSet())
        infolog.docu().note(element);
    else
        infolog.docu().setActive();


    vendDoc = false;
}

Wednesday, 6 July 2011

Client/local printer not available at Terminal Services Session/RDP

There’re several different reasons when local printer is not available at Terminal Services Session, below are my check list, hope it helps.


#1. Printer redirection is disabled at Terminal Server
First thing to check is whether the server has disabled the printer redirection.
Also ensure it enable the use of user settings.


Path: Control Panel > Administrative tools > Terminal Services Configuration


Check group policy
Path: Start > Run > gpedit.msc > Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Terminal Services > Client/Server data redirection
Ensure the printer redirection is not disabled.


Reference:
http://social.technet.microsoft.com/Forums/en/winserverTS/thread/619d78a1-dc47-45cf-a078-e9fba492dd1f
http://social.technet.microsoft.com/Forums/en/winserverTS/thread/4ebf9a34-85f3-4b91-9750-48124b9885ba


#2. Local resources (Printer) is not checked in the RDP connection settings
Ensure the “Printers” checkbox is checked under the “Local devices and resources” group.


#3. Printer driver is not available at Terminal Server
In certain cases, the issue was caused by printer driver is not available at the server, you might want to install it there.


Reference: http://technet.microsoft.com/en-us/library/cc758836(WS.10).aspx


#4. Printer is not using COM, LPT, or USB port
Refer to more details at http://support.microsoft.com/kb/302361.

Monday, 13 June 2011

Candidate for EntireTable CacheLookup on Dynamics AX

When deciding which table is suitable for EntireTable caching in Dynamics AX, the rule is the 128k size limit (http://msdn.microsoft.com/en-us/library/bb314630(v=AX.50).aspx). With the note in MSDN - "Avoid using EntireTable caches for large tables because once the cache size reaches 128 KB the cache is moved from memory to disk. A disk search is much slower than an in-memory search.", so, how do we decide which table should be cached? The easiest way is to look at the page count of the table itself. In SQL Server, 1 page == 8kb, which means 128k == 16 pages. With the help of 'sys.dm_db_index_physical_stats' we can list out all the tables that is less than or equal 16 pages, these will be the candidate for further analysis. Do not change them all to EntireTable CacheLookup, there're further analysis required.


USE <databasename>
GO
SELECT OBJECT_NAME(object_id),
       [object_id],
       index_id,
       index_level,
       page_count,
       avg_fragmentation_in_percent
  FROM sys.dm_db_index_physical_stats(DB_ID('<databasename>'),NULL,NULL,NULL,DEFAULT)
 WHERE page_count  > 0
   AND page_count <= 16
GO


If the system is still in implementation phase, most likely the data is quite crappy, insufficient, or with just a small set of test records, they're not helping in decision making. With the list of tables returned from the above query, do further analysis and ask yourself:
- Is the table potentially growing larger over time?
- Are the data quite static? (avoid doing EntireTable cache on small table, but has high change rate)
- Is the table (unique) index correctly set? (Eg. to the ::find() method or other query's unique criteria)

There's one thing that I'm not quite sure yet, that is whether the 128k limit is per index or per table.
You can test it out by capturing the trace and look at it with Trace Parser.


*NOTE: The query took around 30 minutes to run on my system (~500GB database), you might want to choose a better timing to run it.


To run the query against one single table, replace the second parameter to the object Id of the table.


From: sys.dm_db_index_physical_stats(DB_ID('<databasename>'),NULL,NULL,NULL,DEFAULT)
To: sys.dm_db_index_physical_stats(DB_ID('<databasename>'),OBJECT_ID('<tablename>'),NULL,NULL,DEFAULT)

Monday, 16 May 2011

ExtendedTypeId of Enum and EDT

Just a quick post about the error encountered.
I was asked to debug an error and it has been found that it was due to developer is trying to use the "SysDictType()" class to look for the ExtendedTypeId of an enum. The code is quite dynamic, it accept the input from another setup table, which by default, it won't know what's the field that is coming in.

On the generic code, it seems like there's an assumption all field coming in will have EDT, therefore using only the SysDictType(), hence, error. The EDT name is needed for some other purpose, so I retain it. What I added is a branch to use either SysDictType() or SysDictEnum() based on the existence of the EDT.

Eg.
dictField = new DictField(tableId, fieldId);
if(dictField.typeId())
    extendedTypeId = new sysDictType(dictField.typeId()).extendedTypeId();
else if(dictField.enumId())
    extendedTypeId = new sysDictEnum(dictField.enumId()).extendedTypeId();


Thursday, 12 May 2011

Send/add batch job through code on Dynamics AX

To add job into 'Batch job' using X++ code, just skip the .prompt() method.
All you need is:
- A class that extends RunBaseBatch
- A method that add the job into batch job

Eg.

classdeclaration SendBatchJob extends RunBaseBatch
{
    ....
    ....
}

//The method that calls to add the job
static void addBatchJob()
{
    SendBatchJob    sendBatch;
    ;

    sendBatch = new SendBatchJob();
    sendBatch.sendToBatch();
}

//The method that actually add the job into 'Batch job'
void sendToBatch()
{
    this.batchInfo(); //Initialize
    batchInfo.parmBatchExecute(NoYes::Yes);
    batchInfo.doBatch();
}

Friday, 6 May 2011

Running batch report in AX2009 (batch printing)

Since the change of AX2009 batch framework, printing of report through batch can be done through two methods:
- Printing from server (to printer or file)
- Printing from client (the legacy batch processing)

Prerequisites: For both of the method, there're some mandatory setup:
  1. Enable any of the AOS that you want to make it as batch AOS
    (Administration -> Setup -> Server configuration)

  2. Create batch group for printing.
    Eg. One for client printing and one for server printing.
    (Administration -> Setup -> Batch groups)

  3. Add the batch group created in #2 into the AOS enabled for batch processing (in #1)

Printing from server (print to printer)
  • Enable the 'Allow clients to connect to printers on this server' settings at Dynamics AX Server Configuration Utility under the 'Application Object Server' tab.

  • Enable the 'Connect to printers on the server' settings at Dynamics AX (client) Configuration Utility under the 'Connection' tab

  • When printing report
    > At the 'Batch' tab, check the 'Batch processing' and select the batch group created for server printing
    > Click on the "Option" and select the server printer. Server printers are prefix with 'AOS:'


Printing from server (print to file)
  • Enable the 'Allow clients to connect to printers on this server' settings at Dynamics AX Server Configuration Utility under the 'Application Object Server' tab.

    *Although you're printing to file, but you still need to enable this.

  • When printing report
    > At the 'Batch' tab, check the 'Batch processing' and select the batch group created for server printing
    > Click on the "Option" and select 'File', then ensure the file name is a UNC path (Eg.\\serverName\directory) else you'll get an error.

    *After this job is added to the batch, you can check it at 'Basic > Inquiries > Batch job'. Click on the 'View tasks', notice that the 'Run location' is "Server". If your 'Run location' is "Client", then you might have selected a client printer or your report class method 'runsImpersonated()' has been overwritten to return "false".

Printing from client (through legacy batch processing)
  • When printing report
    > At the 'Batch' tab, check the 'Batch processing' and select the batch group created for client printing
    > Click on the "Option" and select the client printer

  • Run the legacy batch processing (Basic > Periodic > Batch > Processing)

    *After this job is added to the batch, you can check it at Basic > Inquiries > Batch job. Click on the 'View tasks', look at the printing job/task, it will change from "Waiting" to "Ready", then to "Executing". Also notice that the 'Run location' is "Client". The legacy batch processing require the task to be in "Ready" status, this field cannot be changed manually, it is automatically changed if you've done step #3 in the prerequisites (it might not change immediately, give it some time then refresh it and look at the status again).


Some common errors:
  • Use of printers on the server is not allowed
     

    Resolution: Ensure
    the 'Allow clients to connect to printers on this server' settings at Dynamics AX Server Configuration Utility under the 'Application Object Server' tab is checked.

  • Target file must be in UNC format


    Resolution: Ensure when you select 'File' as the output, the 'File name' is UNC path. Eg. \\serverName\directory

  • Selected printer is not an AOS printer


    Resolution: Install the printer driver on the server.
    Sometimes there're confusion regarding AOS printer and shared printer.
    For printing to works in batch mode (running from server), the printer has to be AOS printer, which the printer is "Installed" as printer on the AOS host server, not "Connect" as shared printer.

    Eg.
    There's a print server with 5 printers shared out, the AOS "Connect" to these printers, all these printers will appear as "\\printServerName\printerName01", this will not appear as AOS printer, instead, they're client printer.

    AOS printer is prefix with "AOS: " in front of the printer name in the printer selection list at print dialog.




The old/legacy client batch report printing in AX2009 concept also applies to the class. Let's say you have some process which utilize client code (Eg. needs to read Excel file), they won't run in the new AX2009 batch framework, you can then use the legacy batch processing, ensure the 'runsImpersonated()' method is overwritten to return "false", so that it will be run from client instead of server.

*Updated on 19/06/2012: Added details for "
Selected printer is not an AOS printer"

Thursday, 28 April 2011

YouTube Internal Server Error 500

Got this message while trying to access a video, hey, they employ monkeys, that's hell smart of monkeys they are.
Haha, but of course you won't think that's real monkeys, Google just likes to jokes around.


Just do a refresh/reload, the error will go away (mostly).


============================


500 Internal Server Error
Sorry, something went wrong.
A team of highly trained monkeys has been dispatched to deal with this situation.
If you see them, show them this information:
....
....
....
....




Wednesday, 13 April 2011

Creating serial number in Dynamics AX

If you happen to need serial number for testing your code/functionality, one of the quickest way is to create it manually at the ‘Serial numbers’ form.

Path: Stock management > Inquiries > Dimensions > Serial numbers



Tuesday, 29 March 2011

Create Dynamics AX Trace Parser database

If you're wondering how can you create Dynamics AX Trace Parser database, it's created through the "Register Database" menu.
Here're the step:
1. Open Dynamics AX Trace Parser2. Click on: File > Register Database


Older version of Trace Parser
3. Enter the details for 'DatabaseServer' and 'DatabaseName'

Newer version of Trace Parser (come with AX2012)

4. If the database never exist, it will prompt for confirmation to create the database, else it will just register and use it.


*NOTE: Do not use old/previous version of TraceParser database on a newer TraceParser. Someone might thought, backup the existing DB, restore it and use it on new version of TraceParser, it might looks OK when you start up, but might throw unexpected error when you import trace file or view the existing trace. Another common issue, which is similar to the above, is connecting newer version TraceParser to old TraceParser database.

Tuesday, 7 December 2010

Switching Trace Parser between AX4, AX2009, & AX2012

When Trace Parser is started up, it will login to AX through business connector. If you have different version of AX, it won't prompt to ask about which version of AX it should use. If you need to switch between the version the Trace Parser logon to, you'll need to edit the Trace Parser config file.

Open the file 'Microsoft.Dynamics.AX.Tracing.TraceParser.exe.config' (under the Trace Parser installation path) and edit the line: <bindingRedirect oldVersion="5.0.0.0" newVersion="5.0.0.0"/>

Set the 'newVersion="5.0.0.0"' to the version you want.

Eg.
To logon to AX4: <bindingRedirect oldVersion="5.0.0.0" newVersion="4.0.0.0"/>
To logon to AX2009: <bindingRedirect oldVersion="5.0.0.0" newVersion="5.0.0.0"/>

If that doesn't works, it might be due to the 32/64bit issue.

Below is the excerpt from the an email I received.

=============================

Verify that both 4 and 5 BC.Net are in the GAC by opening up c:\windows\assembly from the start menu. If so, then the following should work:

<bindingRedirect oldVersion="5.0.0.0" newVersion="4.0.0.0" />

If that still doesn’t work, it may be an issue with 32/64 bit. BC.Net has both x86 and x64 for AX2009 but only x86 for AX4. If you have Visual Studio, you could open a visual studio command prompt and run

corflags /32BIT+ Microsoft.Dynamics.AX.Tracing.TraceParser.exe

Combined with the bindingRedirect, this should solve the problem.

=============================

*UPDATE: To connect to AX2012, just do the similar changes to the config file to version 6.0.0.0.

Monday, 6 December 2010

Event ID 117: Changed language setting to us_english.. The SQL statement was: "UPDATE SYSLASTVALUE SET VALUE ...

Below are two of the common errors seen in AX and the explanation of them from Microsoft support.

=========================
Event ID: 117
Description:
Object Server 01: The database reported (session 1 (-AOS-)): [Microsoft][ODBC SQL Server Driver][SQL Server]Changed language setting to us_english.. The SQL statement was: "UPDATE SYSLASTVALUE SET VALUE=?,RECVERSION=? WHERE (((((((USERID=?) AND (RECORDTYPE=?)) AND (ELEMENTNAME=?)) AND (DESIGNNAME=?)) AND (ISKERNEL=?)) AND (COMPANY=?)) AND (RECVERSION=?))"


Event ID: 110
Description:
Object Server 01: Dialog issued for client-less session 1: Cannot edit a record in LastValue (SysLastValue). User ID: , AdminUserSetup.
The SQL database has issued an error.
=========================

 
These messages do not appear constantly, but actually sporadically, and always in pairs, of 110 and 117.

From my research the cause of this is that an update conflict occurs when updating a table with a blob type field, like SysLastValue table. The kernel uses ODBC function SQLParamData to put data into a blob field, in case of an update conflict SQLParamData returns SQL_NO_DATA. The AX kernel misinte rprets this return value, thinking that SQL server has raised an error, and so raises the two messages in the event log - message 110 indicates the update failed, message 117 is the last message raised from SQL server, which is actually just a standard information message that is normally not shown , as there is no actual error from SQL, it is only misinterpretation from AX kernel.