Powered By Blogger

Wednesday, August 10, 2011

Small article on refresh, reread, research, executeQuery - which one to use?

  • All these four methods (refresh, reread, research and executeQuery) on datasource always create panic to the developers irrespective their experience they had in AX about where to use what method.

I've done some research on this during few assignments and here are few findings.

  • Refresh Data displayed in the form controls will get refreshed using this method irrespective of what is stored in form cache for that datasource record. One more important thing, Calling refresh() method will NOT reread the record from the database and so if changes occurs to the record in any other process, those will not be shown after executing refresh().

  • Reread This method will query the database and re-read the current record contents into the datasource. This will not display the changes on the form until a redraw of the grid contents happens (e.g you need to navigate away from the column or re-open the form).


  • Research Existing form query will rerun in database while calling of method research() and therefore updating the list with new/removed records as well as updating all existing rows.

    Research(true) -The research method in DAX 2009 accepts an optional boolean argument _retainPosition. If you call research(true), the cursor position in the grid will be preserved after the data has been refreshed. This is an extremely useful addition, which solves most of the problems with cursor positioning (findRecord method is the alternative, but it may cause some performance issue).

    ExecuteQuery Calling executeQuery() will also rerun the query and update/add/delete the rows in the grid.


Wednesday, April 20, 2011

new menu to the context menu addin - directly add selected objects to the project area

DAX folks,

Requirement always make you tender with your work as its keep on forcing you to do something innovative everyday.

Here one tool I've created which could reduce your time a bit while working with any project and where you have plenty of objects which all you need to add them to shared project also. Generally to add any object you have to navigate to shared project, select your project and then add that object to that space.

In AOT when you do a right click on any object you get plenty of options there, there is one option like "Add-ins" which again shows so many options which could be applied on that object. Under this tool i've modifed "SysContextMenu" class method "verifyItem" to add a new menu to the add-ins (add to share project).
Also to handle this one new class has to be created where treeNode class has been used to get the selected node and add it to the shared project space. Also "SysContextMenu" menu has to be updated with this entry in the existing add-ins pane.

Project xpo could be downloaded from here

Wednesday, April 13, 2011

User 'UserName' is not authorized to insert a record in table 'TableName'. Request denied. Cannot create a record in TableLabel (TableName).

DAX folks,

This was really weird for me while dealing with this issue arises during posting the invoice journal(project>inquiries>Invoice>invoice Journal).

User which was trying to post this had several user groups and among them few of them have "NO ACCESS" to the table 'projInvoiceJour' which i never even thought will make any difference b4 encountering this horrible episode.

After doing some research and analysis it was revealed that AOSAuthorization property on the table is the culprit -:). For handling this there is a line of code which needs to be used where records are getting inserted into this table.

unchecked(Uncheck::TableSecurityPermission)
{
projInvoiceJour.insert();
}


Even easiest thing to handle this is just change the AOSAuthorization property on the specific table but STOP! Don't do that as it will put your data at high risk. So better opt for above script.

Hope you doesn't fight too much and script help.

Monday, April 11, 2011

DAX2009: DateTimeUtil::anyToDateTime()

While working in AX2009, i have been Juggling with anyToDateTime() method of DateTimeUtil class. If you use the below code above error will get encountered on the fly.

UtcDateTime dt;
Date d = 01\03\2009;
;
dt = DateTimeUtil::anyToDateTime(d);
info(strFmt('%1', dt));


In order to get this fixed we have to pass any time by using below method of dateTimeUtil class.

dt = DateTimeUtil::newDateTime(d,str2time('00:00:00'));








Thursday, April 7, 2011

Multiple table properties update

Guys -

Sometimes if you need to update a set of tables (sales*,proj*,purch*,address*) for few properties. You can opt
below script which basically look in all that related tables that are in the database (SQLDictionary) and keep on iterating until all that tables gets updated.



static void ChangeTableProperties(Args _args)
{
SQLDictionary dictionary;
TreeNode treeNode;
str properties;
Counter i;
;
while select dictionary
where dictionary.fieldId == 0 && dictionary.name like("Address*")
{
treeNode = TreeNode::findNode('\\data dictionary\\tables\\' + dictionary.name);
if (treeNode)
{
properties = treeNode.AOTgetProperties();
properties = setProperty(properties, 'CreatedDateTime', 'Yes');
properties = setProperty(properties, 'CreatedBy', 'Yes');
treeNode.AOTsetProperties(properties);
treeNode.AOTsave();
i++;
}
}
info(strfmt("NO of tables which has been updated - %1",i));
}

Where is the code running?

DAX folks,

Sometimes its gets very irritating to identify where is this code running actually, server or client.

Just try adding below info line after the code, it must tell you where the code execution happens.

info(strfmt("%1",xGlobal::clientKind()));

Thursday, March 17, 2011

Custom Lookup - 'group by' doesnt work

ALL,

During on of my project task i was trying for 'group by' on a lookup but strange it works for the first shot when i expanded the lookup and selected any value.
But unfortunately when i tried changing the lookup to some other value again all the values shown up in the lookup and grouping was no more active.

I was really puzzled with all options i was aware of but after further on the 'sysTableLookup' methods, found one method which helps finally.

sysTableLookup.parmUseLookupValue(false); - this should be passed as FALSE.

Hope it helps some of you.


Thanks,