Tuesday, 17 May 2011

Who Modified Ax2009 Object?


Following code will help you that who have modified object last time with date. Copy code and paste it in job. 

static void UserWhoModifiedObjectLastDateandTime(Args _args)
{
UtilIdElements tblUtilIdElements;
;
while select tblUtilIdElements
where (tblUtilIdElements.utilLevel == UtilEntryLevel::USR && tblUtilIdElements.recordType == UtilElementType::Form && tblUtilIdElements.name == "SalesTable")

{

info(strfmt("%1",tblUtilIdElements.modifiedBy + " " + datetime2str(tblUtilIdElements.modifiedDateTime)));
}
}

Tuesday, 5 April 2011

How to check if your variable suit the conditions given in query range

Use inRange methods from Global class

static boolean inRange(str _rangeValue, anytype _value)

Example:

{

str _rangeValue;

str _value ;

boolean result;

;

_rangeValue = ‘200..500’;

_value = ‘300’;


result = Global::inRange (_rangeValue , _value);

}

The result variable will be equal to true


How to set focus when first time opening form in axpta

Override method firstField on a form, and call after super method setFocus of a control which should focused after form is opened. Example:

public void firstField(int _flags=1)
{
;
super(_flags);
MyControlName.setFocus();
}

How dynamically change data source field properties?

myTable_ds.object( fieldNum( myTable, myField ) ).visible( false );
myTable_ds.object( fieldNum( myTable, myField ) ).allowEdit( false );

How to override lookup in Ax2009?

Write following method on form level

void SummaryProjectLookup(FormControl ctrl)
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(ProjTable),ctrl);
Query query = New Query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(ProjTable));
QueryBuildRange queryBuildRange;
;

sysTableLookup.addLookupfield(fieldNum(ProjTable, ProjId));
sysTableLookup.addLookupfield(fieldNum(ProjTable, Name));
sysTableLookup.addLookupfield(fieldNum(ProjTable, Status));

queryBuildRange = queryBuildDataSource.addRange(fieldNum(ProjTable, Type));
queryBuildRange.value(queryValue(ProjType::DEL_Summary));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
*******************************************************************
public void lookup()
{
element.SummaryProjectLookup(this);
}

Tuesday, 29 March 2011

How can I extract the hour, minute and seconds from AX2009 time?

static void time(Args _args)
{
TimeIn _TimeIn;
int hourInt, minuteInt , SecondInt;
str s;
;

_TimeIn = str2time('5:45');


s = time2str(_TimeIn,0,0);
info(strfmt("%1",s));

hourInt= str2int(substr(s,0,2));
info(strfmt("%1" ,hourInt));
minuteInt= str2int(substr(s,4,2));
info(strfmt("%1" ,minuteInt));
SecondInt= str2int(substr(s,7,2));
info(strfmt("%1" ,SecondInt));

}

Sunday, 27 March 2011

How to get current language of AX2009?

using following code

info( infolog.language());