Powered By Blogger

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()));