DAXSPOT

Thursday, May 30, 2019

Error Access Denied while generating Full/Incremental CIL Ax 2012

Hi,

Today i faced an issue where i needed to generate Full/Incremental CIL, but i was not able to generate.

Error:
Access to the path 'C:\Program Files\Microsoft Dynamics AX\60\Server\AOSName\Bin\XppIL\xml\AppObjects1.xml' is denied.

Solution:

1. Goto the Aos services i.e.., Win+R then type services.msc and press OK and search your AOS.

2. check the "Log on as" column of your particular aos, "Log on as" will have user name which runs AOS.

3. Then press Win+R and type compmgmt.msc and press OK.

4. Then navigate to System Tools -> Local Users and Groups -> Groups -> then right click on 
"Administrators" in right pane -> properties -> check if the user name in step 2 is there, if not then add the user.

5. Stop AOS.

6. Backup XppIL folder and delete it from Bin folder.

7. Start the AOS.

8. Perform Full CIL.

Tuesday, May 21, 2019

Lookup in form string control

Hi,
Below is an example of the lookup in form string control.
First Go to the string control and override the lookup method, then copy the below code. Change the code as per your requirement.
public void lookup()
{
    Query query;
    QueryBuildDataSource datasourceModule;
    QueryBuildDataSource datasourceLanguage;
    QueryBuildRange rangeElementType;
    QueryBuildRange rangeModuleId;
    SysTableLookup sysTableLookup;
 
    query = new Query();
//Add table in Query build datasource
    datasourceLanguage = query.addDataSource(tableNum(SalesTable));
//pass a range, here i need salesOrder with Backorder status only   
    datasourceLanguage.addRange(
        fieldNum(SalesTable, SalesStatus)).value(queryValue(SalesStatus::BackOrder));
//add the lookup table
    sysTableLookup = SysTableLookup::newParameters(tableNum(SalesTable), this);

//Add which field to show in lookup
    sysTableLookup.addLookupfield(fieldNum(SalesTable, SalesId));

//add the above build query to the lookup Query
    sysTableLookup.parmQuery(query);

//at last perform the lookup.
    sysTableLookup.performFormLookup();

}

Enable mark for grid

Hi,
To enable mark row in grid, just change property ShowRowLabels for grid.
ShowRowLabels : yes
Happy Daxing 😃

Monday, May 20, 2019

Generate Random Integer

Hi,
Today i faced an scenario, where i need to generate a OTP for specific number of digits. With help of some blog references i got to achieve it.
Below code helped me to achieve the requirement.

RandomGenerate randomGenerate;
randomGenerate = RandomGenerate::construct();
randomGenerate.parmSeed(new Random().nextInt());
switch(numberOfDigits)
{
case 5:
RandomNo = randomGenerate.randomInt(10001,99999); //5 digits
break;
case 9:
RandomNo = randomGenerate.randomInt(100000001,999999999); //9 digits
break;
}

Display number of years in a lookup

Hi,

Today i got a requirement to show number of years in lookup.
This post will help you to show specific number of years in a look up.


public void lookup()
{
    Counter yearCount;
    List    valueList = new List(Types::String);

    for (yearCount = 0; yearCount < 5; yearCount++) //here 5 is number of years to show
    {
        valueList.addEnd(strFmt("Year %1", year(SystemDateGet()) - yearCount)); //getting system date year and minus with the count and add in list
    }

    SysLookup::lookupList(this, valueList, "List of years");
}


Happy Daxing! 😃

Wednesday, May 15, 2019

month Difference between two dates - X++

Hi,
Below small code will help to get the number months difference between two dates in ax 2012.
intvNo(fromDate, toDate, intvScale::Month);
intvScale has many values which can be used to get difference Day, Month, MonthDay, Quarter, Week, WeekDay, Year etc.

Get terminated employees or worker from payroll module - X++ Code

Hi,

Today i got a scenario while working in payroll module, to get the terminated workers only using x++ query or adhoc query.

Below code helped me to achieve the requirement.

subQuery       =   new Query();
qbdsEmployment = subQuery.addDataSource(tableNum(HcmWorker));
qbdsEmployment.addSelectionField(fieldNum(HcmWorker, PersonnelNumber));
qbdsEmployment = qbdsEmployment.addDataSource(tableNum(HcmEmployment));
qbdsEmployment.joinMode(JoinMode::InnerJoin);
qbdsEmployment.relations(true);
qbdsEmployment.addLink(fieldNum(HcmEmployment,Worker),fieldNum(HcmWorker,RecId));
//workerRange  =   qbdsEmployment.addRange(fieldNum(HcmEmployment, Worker));
validFromRange = qbdsEmployment.addRange(fieldNum(HcmEmployment, ValidFrom));
validToRange   = qbdsEmployment.addRange(fieldNum(HcmEmployment, ValidTo));
subQuery.validTimeStateDateTimeRange(DateTimeUtil::minValue(), DateTimeUtil::utcNow());
validFromRange.value(SysQuery::valueUnlimited());
validToRange.value(SysQueryRangeUtil::lessThanUtcNow());
qbdsEmployment.addSelectionField(fieldNum(HcmEmployment,Worker));
qbdsEmployment.addSelectionField(fieldNum(HcmEmployment,ValidFrom));
qbdsEmployment.addSelectionField(fieldNum(HcmEmployment,ValidTo));

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...