Friday, December 18, 2015
Form personalization is lock in AX 2009
One of the reason you cannot move fields around, and there is a lock icon on the Setup view of the form. And it is that you have some code in the method "tabChanged()" on the tab of the form. This causes the form to be locked for personalization. So if you move to use method "pageActivated" on each tab, it will work.
Monday, November 16, 2015
Same object is used for more than 1 company select
You might stumble on an issue where you declare one variable of a table and use it for more than 1 company select. It will not work properly if you want to save it. The best approach is to create separate variable for each company. For some reason, AX doesn't clear the DataAreaId on the object such as table. Even if you set it to null.
Example: Will not work properly.
CustTable CT;
;
CT.AccountNum = 'test';
....
CT.insert();
CT = null;
changecompany('2ndcompany')
{
CT.AccountNum = 'test2';
CT.insert();
}
Correct Approach
CustTable CT,CT2;
;
CT.AccountNum = 'test';
....
CT.insert();
CT = null;
changecompany('2ndcompany')
{
CT2.AccountNum = 'test2';
CT2.insert();
}
Example: Will not work properly.
CustTable CT;
;
CT.AccountNum = 'test';
....
CT.insert();
CT = null;
changecompany('2ndcompany')
{
CT.AccountNum = 'test2';
CT.insert();
}
Correct Approach
CustTable CT,CT2;
;
CT.AccountNum = 'test';
....
CT.insert();
CT = null;
changecompany('2ndcompany')
{
CT2.AccountNum = 'test2';
CT2.insert();
}
Thursday, October 1, 2015
Object ID conflict and data synchronization between AX databases
You must have noticed that when you have 2 AX environments, one for development and one for Live. If you have the issue where you make a whole DB copied from LIVE to DEV to get test data in the development environment, you notice that some of added custom fields do not get the data.
This could be caused by ID conflict between the 2 AX. So you must keep the ID sync between the 2 AX in order for the data to be sync. So one system must be the place for all the objects to be created, the other system must be the receiving one.
This could be caused by ID conflict between the 2 AX. So you must keep the ID sync between the 2 AX in order for the data to be sync. So one system must be the place for all the objects to be created, the other system must be the receiving one.
Monday, September 21, 2015
AX Role Center loading takes a long time
If your Role Center on AX 2009 is taking a long time. It's possible that your EventInbox needs to be cleaned up. There are different types of alerts in this table so be careful on cleaning up because you may delete the records you want to keep.
Wednesday, September 9, 2015
Flush the AOS cache from code
[from internet source: http://dynamics-ax.blogspot.ca/2006/04/flush-aos-cache-from-code.html]
Well while working on a current project an associate of mine, partner in crime on the current project named Ed (from Stream Line), shared with me a very nice little trick.
You see we had two AOSes that we needed to flush the cache, but could not stop and start the AOSes. The only way I have ever known to flush the AOS is to stop and start it. Well Ed showed me a nice little trick. You may or may not be aware of three menu action items that can be used to flush system data, the AOD, and dictionary. The thing about these though is that they are set to run at "called from" which when ran clear the client cache.
Well the trick is to copy these three menu items, and then change the run from property to server. Now you can launch these menu items, and they will run on the server, therefore clearing the AOD, sys data, and dictionary, causing a refresh.
So the three menu items that you copy (don't change the real deals) are:
[Under Menu items > Action]
1. SysFlushAOD
2. SysFlushData
3. SysFlushDictionary
This is a nice little trick that we should all keep in our bags. Thanks Ed for sharing, and check back soon for more helpful post.
Well while working on a current project an associate of mine, partner in crime on the current project named Ed (from Stream Line), shared with me a very nice little trick.
You see we had two AOSes that we needed to flush the cache, but could not stop and start the AOSes. The only way I have ever known to flush the AOS is to stop and start it. Well Ed showed me a nice little trick. You may or may not be aware of three menu action items that can be used to flush system data, the AOD, and dictionary. The thing about these though is that they are set to run at "called from" which when ran clear the client cache.
Well the trick is to copy these three menu items, and then change the run from property to server. Now you can launch these menu items, and they will run on the server, therefore clearing the AOD, sys data, and dictionary, causing a refresh.
So the three menu items that you copy (don't change the real deals) are:
[Under Menu items > Action]
1. SysFlushAOD
2. SysFlushData
3. SysFlushDictionary
This is a nice little trick that we should all keep in our bags. Thanks Ed for sharing, and check back soon for more helpful post.
Friday, July 24, 2015
Re-calculate InventSum Table
Original Link: http://mvpdynamicsax.blogspot.ca/2013/01/recalculate-inventsum.html
InventSum is needed to recalculate sometimes.We should use InventSumRecalcItem class in Dynamics AX.
Sample Code :
// CODE BEGIN ****************************
InventSumRecalcItem InventSumRecalcItem;
;
InventSumRecalcItem = new InventSumRecalcItem("ITEM001", true, checkfix::fix);
InventSumRecalcItem.updatenow();
// CODE END ******************************
First parameter : ItemId
Second parameter : Show errors
Third parameter : Fix or only check
If you want to calculate for all items :
// CODE BEGIN ****************************
InventTable InventTable;
InventSumRecalcItem InventSumRecalcItem;
;
WHILE SELECT InventTable
WHERE (InventTable.ItemType == ItemType::Item) || (InventTable.ItemType == ItemType::BOM)
{
InventSumRecalcItem = new InventSumRecalcItem(InventTable.ItemId, true, checkfix::fix);
InventSumRecalcItem.updatenow();
}
// CODE END ******************************
InventSum is needed to recalculate sometimes.We should use InventSumRecalcItem class in Dynamics AX.
Sample Code :
// CODE BEGIN ****************************
InventSumRecalcItem InventSumRecalcItem;
;
InventSumRecalcItem = new InventSumRecalcItem("ITEM001", true, checkfix::fix);
InventSumRecalcItem.updatenow();
// CODE END ******************************
First parameter : ItemId
Second parameter : Show errors
Third parameter : Fix or only check
If you want to calculate for all items :
// CODE BEGIN ****************************
InventTable InventTable;
InventSumRecalcItem InventSumRecalcItem;
;
WHILE SELECT InventTable
WHERE (InventTable.ItemType == ItemType::Item) || (InventTable.ItemType == ItemType::BOM)
{
InventSumRecalcItem = new InventSumRecalcItem(InventTable.ItemId, true, checkfix::fix);
InventSumRecalcItem.updatenow();
}
// CODE END ******************************
Friday, July 17, 2015
Dynamics AX – Periodic maintenance and performance analysis
Copy content from:
https://shekhardiptiman.wordpress.com/2010/01/14/dynamics-ax-%E2%80%93-periodic-maintenance-and-performance-analysis/
https://shekhardiptiman.wordpress.com/2010/01/14/dynamics-ax-%E2%80%93-periodic-maintenance-and-performance-analysis/
Periodic clean up – Significance
A recent AX_Database analysis showed that the 5 largest tables in the database account for roughly 60% of the database size. The 4 largest tables out of 5 are tables with temporary and/or archival data: Inventory settlements (INVENTSETTLEMENT), database log (SYSDATABASELOG), temporary sales orders data (SALESPARMLINE), temporary master planning data (INVENTSUMLOGTTS). The fifth table is sales lines (SALESLINE). Periodically archiving/purging these tables would significantly reduce database size and will have beneficial effect on system performance.
Each individual table and related considerations are discussed below:
1.1 Inventory settlements.
The inventory settlements table is used to store information generated during inventory close and adjust periodic job run. This table can be cleaned up/compressed using the
Inventory management>Periodic>Clean up>Inventory settlements clean up.
Deleting cancelled settlement is a recommended procedure (when an inventory settlement/adjustment is cancelled the system does not remove the original adjustment but generates a set of reverse adjustments). The clean up procedure will remove both the original set of adjustments and the reversing set.
Please note that Grouping (compressing) settlements should be used with care as compression cannot be reversed and settlements for compressed periods cannot be reversed as well. That means that it is better to use this function only for previous financial years (i.e. group settlements posted before date should typically current date – 1 year).
The Inventory settlements clean up can be batch-scheduled, takes a few hours to run and is best to be scheduled overnight or on the weekend.
The suggested schedule is once per quarter.
The batch job can be setup to run this procedure over night but the dates will have to be changed before every batch is run. E.g. the batch can be setup to run at 12:00 am to purge transactions of a year ago.
Note: The purge date will have to be changed manually before every batch job as AX will not calculate a rolling date of when transactions need to be purged
Note: Please see the document on Batch job procedures for information in setting up a batch job.
1.2 Database log
The database log table is used to store logging information generated according to the log rules set up in Administration>Setup>Database log.
There are 2 main points to consider for database log maintenance.
The first one is that there should not be excessive logging. The database log setup should be reviewed and some of the rules (such as logging of all changes on sales lines) were removed. When new rules are added it is important to analyse the entries generated in the log to see that no excessive logging is performed.
The second consideration is that the database log should be cleaned up periodically. The log can be backed up to a binary or .csv file if required using AX data export-import utility and the clean up routine is accessible via Administration>Inquiries>Database log>Clean up log(button).
Keeping one month of logs in the system is probably sufficient especially if they are backed up to the file system.
Please note that running clean up for the first time will take significant time and affect system performance because of the amount of log data accumulated. The task can be batch-scheduled.
The suggested schedule is once per month.
Back up database log:
Create a definition group for database log Administration/Periodic/Data export/Import/Definition group
- CTRL N to create a new definition group.
- Specify a meaningful name and select type Excel to create an Excel file to back up.
- Click OK
- Click on the Table setup button
- Select all the tables and click Delete
- Enter ‘DatabaseLog’ in the table name, Export status = Export to, Specify the file name where the back up must be saved.
- Close form
- To Export file click on the Export to button, click OK button if file should be saved to the path specified in the definition group (Previous example) or click on ‘Override file names specified in definition group’ and specify a different file name.
1.3 Temporary sales order/purchase order processing data
Temporary sales order
This table stores temporary sales order line entries when a sales order is posted. The temporary lines are not deleted after posting and need to be cleaned up periodically. The clean up job can be accessed via
Accounts receivable > Periodic > Clean up > Sales update history clean up.
Delete both executed and errorneous data. There is no reason to keep more than a month’s data. Please note that running for the first time will take significant time and affect system performance because of the amount of log data accumulated. The task can be batch-scheduled.
The suggested schedule is once per month.
Note: there is a similar job in the AP module,
1.4 Temporary master planning data.
Table : InventSumLogtts
This table stores inventory movements data used by dynamic master planning. The table is supposed to be automatically purged when a dynamic master plan is run. If there are test companies in the production environment then it would add up data in this table.
Also there is no periodic job to clean up this table, so typically if a company does not use master planning data must be deleted from the table manually (e.g. using SQL server).
It might be beneficial to check this table immediately after master planning session is run to see if it purges correctly.
1.5 Sales line
This table stores sales lines. There is a periodic job in the system that can either delete or void (move to another table) closed (invoiced or cancelled) sales order lines. The job is accessible via AR>Periodic> Delete orders.
Depending on the “Mark orders as voided” check box in AR Parameters the sales orders selected in the Delete orders periodic job will either be completely deleted from the system or moved to the voided orders table.
2 Non-production companies in the Production system
Check if the client uses test companies (e.g. TST) in production environment which for example account for around 40% of all data in the inventory settlement table.
It is not recommended to keep test companies in the production environment. If a copy of live data is required it is recommended to restore a live database backup into a separate test environment. The recommendation is to delete non-production companies from the production environment, which would lead to signinficant reduction in table sizes and index sizes.
If there is a requirement to copy a single company only without using the database backup standard dynamics AX import-export utility can be used to achieve this, but the SQL database back up is a faster method.
3 Periodic indexing
Table indexes should be rebuilt periodically to ensure optimum data query performance. Re-indexing should be done periodically and is accessible via Administration>Periodic>SQL administration
Recommended schedule is weekly. Indexing must also be done after any significant update to master file data, e.g. reassigning customers to a new dimension etc.
Wednesday, July 15, 2015
Cannot edit a record in On-hand inventory (InventSum).
We cannot modify the inventSum directly in AX. We should run the class from AX. Here is how to do it. I copied from another AX developer.
Link: http://mvpdynamicsax.blogspot.nl/2013/01/recalculate-inventsum.html
Link: http://mvpdynamicsax.blogspot.nl/2013/01/recalculate-inventsum.html
Recalculate InventSum
InventSum is needed to recalculate sometimes.We should use InventSumRecalcItem class in Dynamics AX.
Sample Code :
// CODE BEGIN ****************************
InventSumRecalcItem InventSumRecalcItem;
;
InventSumRecalcItem = new InventSumRecalcItem("ITEM001", true, checkfix::fix);
InventSumRecalcItem.updatenow();
// CODE END ******************************
First parameter : ItemId
Second parameter : Show errors
Third parameter : Fix or only check
If you want to calculate for all items :
// CODE BEGIN ****************************
InventTable InventTable;
InventSumRecalcItem InventSumRecalcItem;
;
WHILE SELECT InventTable
WHERE (InventTable.ItemType == ItemType::Item) || (InventTable.ItemType == ItemType::BOM)
{
InventSumRecalcItem = new InventSumRecalcItem(InventTable.ItemId, true, checkfix::fix);
InventSumRecalcItem.updatenow();
}
// CODE END ******************************
Sample Code :
// CODE BEGIN ****************************
InventSumRecalcItem InventSumRecalcItem;
;
InventSumRecalcItem = new InventSumRecalcItem("ITEM001", true, checkfix::fix);
InventSumRecalcItem.updatenow();
// CODE END ******************************
First parameter : ItemId
Second parameter : Show errors
Third parameter : Fix or only check
If you want to calculate for all items :
// CODE BEGIN ****************************
InventTable InventTable;
InventSumRecalcItem InventSumRecalcItem;
;
WHILE SELECT InventTable
WHERE (InventTable.ItemType == ItemType::Item) || (InventTable.ItemType == ItemType::BOM)
{
InventSumRecalcItem = new InventSumRecalcItem(InventTable.ItemId, true, checkfix::fix);
InventSumRecalcItem.updatenow();
}
// CODE END ******************************
Wednesday, April 29, 2015
Send email by batch with attachment - AX 2009
You must have a shared folder so that AX service account has full permission on it.
You also need to turn on the "Allow to connect printers.. " on AX server configuration and AX client configuration
Sample code:
InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
SysMailer mailer;
SysEmailParameters parameters;
Set permissionSet;
System.Exception e;
BatchJob _BatchJobDelete, bj;
int j;
FileIOPermission _perm;
;
info("After code access in EmailCheck()");
permission.assert();
mailer = new SysMailer();
parameters = SysEmailParameters::find();
if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
mailer.fromAddress(this.getmailFrom());
mailer.tos().appendAddress(this.getMailTo());
if (mailCC2 != connull())
{
for(j=1;j<=conlen(mailCC2);j++)
mailer.ccs().appendAddress(strfmt('%1',conpeek(mailCC2,j)));
//mailCCCollection.Add(strfmt('%1',conpeek(mailCC2,j)));
}
mailer.htmlBody(this.getMailBody());
mailer.subject(this.getmailSubject());
info(pdfFileName);
mailer.sendMail();
info("sent mail");
CodeAccessPermission::revertAssert();
_perm = new FileIOPermission(pdfFileName,'rw');
_perm.assert();
if(WinAPIServer::fileExists(pdfFileName))
WinAPIServer::deleteFile(pdfFileName);
How to change Status of Withhold Batch job to Waiting - AX 2009
On class BatchChangeStatus, comment the Return to allow changing status if AX doesn't allow to change .
static void main(Args args)
{
BatchChangeStatus changeStatus;
changeStatus = new BatchChangeStatus();
BatchChangeStatus::initFromForm(changeStatus,args);
if (! changeStatus.prompt())
// return; //20150429 allow to change status
changeStatus.run();
if (args.caller())
{
args.caller().doReselect();
}
}
static void main(Args args)
{
BatchChangeStatus changeStatus;
changeStatus = new BatchChangeStatus();
BatchChangeStatus::initFromForm(changeStatus,args);
if (! changeStatus.prompt())
// return; //20150429 allow to change status
changeStatus.run();
if (args.caller())
{
args.caller().doReselect();
}
}
Subscribe to:
Posts (Atom)