5 Dec 2019

Create number sequence in D365 FO

  1. Create the data type.
  2. Add code in the loadModule method of the appropriate NumberSeqModule subclass.
  3. Add a method to the module’s parameters table that returns a reference to the number sequence.
To create the number sequence, we need to extend the loadModule method of the appropriate NumberSeqModule subclass. For example, if we wish to add the number sequence to Accounts Receivable, we will use NumberSeqModuleCustomer. Using chain of command, we extend this class with a new class like the following.

[ExtensionOf(classStr(NumberSeqModuleCustomer))]
final class NumberSeqModuleCustomer_Extension

    protected void loadModule()
    {
        next loadModule();
     
        NumberSeqDatatype datatype = NumberSeqDatatype::construct();

        datatype.parmDatatypeId(extendedTypeNum(CustomerChargesID));
        datatype.parmReferenceHelp("Cusromer Charges NumSeq");
        datatype.parmWizardIsContinuous(false);
        datatype.parmWizardIsManual(NoYes::No);
        datatype.parmWizardIsChangeDownAllowed(NoYes::No);
        datatype.parmWizardIsChangeUpAllowed(NoYes::No);
        datatype.parmWizardHighest(999999);
        datatype.parmSortField(151);
        datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);

        this.create(datatype);
    }

}

The last step is to add a method that returns a reference to the number sequence. The best practice is to put the method on the module’s parameters table. Like the NumberSeqModule class, we need to extend the table’s class. This code should look like the following.

[ExtensionOf(tableStr(CustParameters))]
final class ARDCustparameters_Extension
{
    public static NumberSequenceReference numRefCustomerChargesID()
    {
        return NumberSeqReference::findReference(extendedTypeNum(CustomerChargesID));
    }


}

Like the NumberSeqModule subclass, the name of the class needs to end with “Extension” and to use the ExtensionOf attribute (be careful to not use classStr instead of tableStr ). There does not need to be a next statement as this is a new method.

class GenerateCustChargeIDNumberSequence
{        
   
    public static void main(Args _args)
    {     
        NumberSeqModuleCustomer module = new NumberSeqModuleCustomer();
        module.load();

        info('Number Sequence Loaded');
    }


}

3 Dec 2018

Import project dimensions through CSV in AX 2012

static void Explorer_UpdateProjDim(Args _args)
{
    container           readCon;
    Dialog              dialog;
    DialogField         dialogField;
    FileName            fileName;
    Struct              struct;
    ProjId              projId;
    ProjTable           projTable;
    container           ledgerDimension;
    CommaTextIO         commaIO;
    int                 i, records;
    #File

    #file
    dialog = new Dialog ("Select Project Master CSV File");
    dialogField = dialog.addField(extendedTypeStr(FilenameOpen));
    dialog.filenameLookupFilter(['*.CSV']);
    if (dialog.run())
    {
        fileName = dialogField.value();
        if(!filename)
        {
            throw error('Filename must be filled');
        }
    }

    commaIO = new CommaTextIo(fileName, 'r');
    commaIO.inFieldDelimiter(',');
    readCon = commaIO.read();
    if (commaIO)
    {
        ttsBegin;
        while (commaIO.status() == IO_Status::ok)
        {
            readCon = commaIO.read();

            if (readCon)
            {
                projId = conPeek(readCon, 1);
                struct = new Struct();

                struct.add('Brand', conPeek(readCon, 2)); // specify dimensions
                struct.add('Client', conPeek(readCon, 3)); // specify dimensions
                struct.add('MasterClient', conPeek(readCon, 4)); // specify dimensions
                struct.add('Product', conPeek(readCon, 5)); // specify dimensions

                ledgerDimension = conNull();
                ledgerDimension += struct.fields();
                for (i = 1; i <= struct.fields(); i++)
                {
                    ledgerDimension += struct.fieldName(i);
                    ledgerDimension += struct.valueIndex(i);
                }

                projTable = projTable::find(projId, true);
                if(projTable)
                {
                    projTable.DefaultDimension = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
                    if(projTable.validateWrite())
                    {
                        projTable.update();
                        records++;
                    }
                }
                else
                {
                    error(strFmt("Projid:%1 not exists", projId));
                }
           }
       }
       ttsCommit;
    }
    info(strFmt("%1 records Updated", records));
}

13 Nov 2018

Export customer address with LocationID to Excel Through code in AX 2012

static void AXAPTAEXP_ExportCustomerAddress(Args _args)
{
    #file
    CustTable               custTable;
    DirPartyTable           dirPartyTable;
    DirPartyLocation        dirPartyLocation;
    LogisticsLocation       logisticsLocation;
    LogisticsPostalAddress  logisticsPostalAddress;
    SysExcelApplication     application;
    SysExcelWorkbooks       workbooks;
    SysExcelWorkbook        workbook;
    SysExcelWorksheets      worksheets;
    SysExcelWorksheet       worksheet;
    SysExcelCells           cells;
    SysExcelCell            cell;
    SysExcelFont            font;
    int                     row;
    LogisticsPostalAddressView      view;
    fileName                fileName = "D:\\ address Export\\CustAddress.xlsx";
    FileIoPermission        filepermission;

    // intializing classes to export excel
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    workbook = workbooks.add();
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    cells.range('A:A').numberFormat('@');

    if (WINAPI::fileExists(fileName))
    {
        WINAPI::deleteFile(fileName);
    }

    // Setting Header values
    cell = cells.item(1, 1);
    cell.value("AccountNum ");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 2);
    cell.value("LocationID");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 3);
    cell.value("Name ");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 4);
    cell.value("Address");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 5);
    cell.value("State ");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 6);
    cell.value("City");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 7);   
    cell.value("CountryRegionId ");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 8);
    cell.value("Street");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 9);
    cell.value("County ");
    font = cell.font();
    font.bold(true);

    cell = cells.item(1, 10);
    cell.value("ZipCode");
    font = cell.font();
    font.bold(true);
    row = 1;

    // inserting data row wise
    while select AccountNum, Party from custTable
            join RecId from dirPartyTable
                    where   dirPartyTable.RecId == custTable.Party
            join Location, Party from dirPartyLocation
                    where   dirPartyLocation.Party == custTable.Party
            join RecId, Description, LocationID from logisticsLocation
                    where   logisticsLocation.RecId == dirPartyLocation.Location
                join logisticsPostalAddress
                     where   logisticsPostalAddress.Location == logisticsLocation.RecId
    {
        LogisticsPostalAddress = LogisticsPostalAddress::findByLocation(LogisticsLocation::findByLocationId(logisticsLocation.LocationID).RecId);
        row++;
        cell = cells.item(row, 1);
        cell.value(any2str(custTable.AccountNum));
        cell = cells.item(row, 2);
        cell.value(any2str(logisticsLocation.LocationId));
        cell = cells.item(row, 3);
        cell.value(any2str(logisticsLocation.Description));
        cell = cells.item(row, 4);
        cell.value(any2str(LogisticsPostalAddress.Address));
        cell = cells.item(row, 5);
        cell.value(any2str(LogisticsPostalAddress.State));
        cell = cells.item(row, 6);
        cell.value(any2str(LogisticsPostalAddress.City));
        cell = cells.item(row, 7);
        cell.value(any2str(LogisticsPostalAddress.CountryRegionId));
        cell = cells.item(row, 8);
        cell.value(any2str(LogisticsPostalAddress.Street));
        cell = cells.item(row, 9);
        cell.value(any2str(LogisticsPostalAddress.County));
        cell = cells.item(row, 10);
        cell.value(any2str(LogisticsPostalAddress.ZipCode));
    }
    application.displayAlerts(false);
    worksheet.columns().autoFit();
    workbook.saveAs(fileName);
    workbook.comObject().save();
    workbook.saved(true);
    application.quit();

    info(strFmt("File saved in %1", fileName));
}

18 Oct 2018

Update Customer/Vendor address through code in AX 2012

static void updatecustomeraddress(Args _args)
{
    CustTable               custTable;
    DirPartyTable           dirPartyTable;
    DirPartyLocation        dirPartyLocation;
    DirPartyLocationRole    dirPartyLocationRole;
    LogisticsLocation       logisticsLocation;
    LogisticsLocationRole   logisticsLocationRole;
    LogisticsPostalAddress  logisticsPostalAddress; 

     while select * from custTable where custTable.AccountNum == "BRIG"  // if you want vendor change here
            join dirPartyTable
                    where   dirPartyTable.RecId == custTable.Party
            join dirPartyLocation
                    where   dirPartyLocation.Party == custTable.Party
// if you want role specific un-commented below code
            /*join dirPartyLocationRole
                    //where   dirPartyLocationRole.PartyLocation == dirPartyLocation.RecId
            //join logisticsLocationRole
                    //where   logisticsLocationRole.RecId == dirPartyLocationRole.LocationRole
                        // &&      logisticsLocationRole.Type ==  LogisticsLocationRoleType::Delivery*/
            join logisticsLocation
                    where   logisticsLocation.RecId == dirPartyLocation.Location
                join logisticsPostalAddress
                     where   logisticsPostalAddress.Location == logisticsLocation.RecId
    {

            ttsbegin;
            logisticsPostalAddress.selectForUpdate(true);
            logisticsPostalAddress.ValidTimeStateUpdateMode (ValidTimeStateUpdate::Correction);
            logisticsPostalAddress.Address = "Test address";
            logisticsPostalAddress.update();         
            ttsCommit;
    }

}

Get Customer/Vendor address through code in AX 2012

static void getCustomerAddress(Args _args)
{
    CustTable               custTable;
    VendTable               vendTable;
    DirPartyTable           dirPartyTable;
    DirPartyLocation        dirPartyLocation;
    DirPartyLocationRole    dirPartyLocationRole;
    LogisticsLocation       logisticsLocation;
    LogisticsLocationRole   logisticsLocationRole;
    LogisticsPostalAddress  logisticsPostalAddress; 


     while select * from custTable where custTable.AccountNum == "BRIG" // if you want vendor specify vendor here
            join dirPartyTable
                    where   dirPartyTable.RecId == custTable.Party
            join dirPartyLocation
                    where   dirPartyLocation.Party == custTable.Party
//If you need fetch based on role use below commented code
            /*join dirPartyLocationRole
                    //where   dirPartyLocationRole.PartyLocation == dirPartyLocation.RecId
            //join logisticsLocationRole
                    //where   logisticsLocationRole.RecId == dirPartyLocationRole.LocationRole
                        // &&      logisticsLocationRole.Type == LogisticsLocationRoleType::Delivery*/
            join logisticsLocation
                    where   logisticsLocation.RecId == dirPartyLocation.Location
                join logisticsPostalAddress
                     where   logisticsPostalAddress.Location == logisticsLocation.RecId
    {
            info(strFmt("%1", logisticsPostalAddress.Address));
         
     }
     
}

26 Sept 2018

Generate random numbers in AX 2012

Sometimes required generate a random number between given range.
There is a class RandomGenerate for generate random numbers. 
See below example, My requirement generate random numbers with 9 digits .


static void AXExplorer_Randomnumber(Args _args)
{

    RandomGenerate randomGenerate;    
    int                          randomNumber;

    randomGenerate = RandomGenerate::construct();
    randomGenerate.parmSeed(new Random().nextInt());     
    randomNumber = RandomGenerate.randomInt(100000000, 999999999);  // need to specify range
    info(strFmt("%1", randomNumber));
    
}

25 Sept 2018

Import Vendor address with Purpose field in AX 2012

Recently i came across when importing Vendor address need to import Purpose field also.
In standard code its not there.
I made changes in entity level, may be it will useful to somebody.

First add field into staging table. (Type)



add code into entity class.


Share excel sheet with client for corresponding data.




8 May 2018

Assign Roles To User through code + AX 2012

static void AssignRoleToUser(Args _args)

{
    SecurityRole        role;
    SecurityUserRole    userRole;
    boolean             added;
    UserInfo            userInfo;
    Name                userRoleName;
    UserId              userId;
    container           userRoleContainer;
    int                 counter;

    userId       = 'AXAPTAEXPLORER';

    userRoleContainer = conIns(userRoleContainer, 1, "Budget clerk");
    userRoleContainer = conIns(userRoleContainer, 2, "Budget manager");
    userRoleContainer = conIns(userRoleContainer, 3, "Buying agent");

    for (counter = 1; counter <= conLen(userRoleContainer); counter++)
    {

        userRoleName = conPeek(userRoleContainer, counter);

        select role where role.Name == userRoleName;

        if (role.RecId)
        {
            while select userInfo
                where userInfo.id == userId
            {
                select * from userRole
                    where userRole.SecurityRole == role.RecId
                       && userRole.User == userInfo.id;

                if (!userRole || (userRole.AssignmentStatus != RoleAssignmentStatus::Enabled))
                {
                    userRole.User              = userInfo.id;
                    userRole.SecurityRole      = role.RecId;
                    userRole.AssignmentMode    = RoleAssignmentMode::Manual;
                    userRole.AssignmentStatus  = RoleAssignmentStatus::Enabled;
                    SecuritySegregationOfDuties::assignUserToRole(userRole, null);

                    info(strFmt('Role %1 added to the user %2 successfully.', role.Name, userInfo.id));
                }
                else
                {
                    warning(strFmt('skipping – Role %1 already assigned to the user %2.', role.Name, userInfo.id));
                }
            }
        }
    }
}

7 May 2018

Get List of all menuitems or list of objects from AOT in AX 2012

Before Run the Job, Create Table (Testtable) with fields MenuItemName, menuItemObject (You can extend with Name).

When you run the below Job data will populate in TestTable.

static void ListOfAllMenuitemsinAOT(Args _args)
{
    UtilElements       utilElements;
    UtilEntryLevel    LayerName = UtilEntryLevel::usr;
    TreeNode            treeNode;
    TestTable            testTable;
    #Properties
    #AOT

    delete_from  testTable;

    while select utilElements
        where utilElements.recordType == UtilElementType::ActionTool && utilElements.name like "axl*"
           // && utilElements.utilLevel == LayerName  //for layers filtering
    {
        treeNode = xUtilElements::getNodeInTree(xUtilElements::parentElement(utilElements));

        testTable.MenuItemName = utilElements.name;
        testTable.menuItemObject = treeNode.AOTgetProperty(#PropertyObject);

        if(testTable.menuItemObject != "")
        {
            testTable.insert();
        }
   
    }

}

22 Nov 2017

Create new Form and Basics about Forms in D365

How to crate new form in D365.

It is simple 
1) First create new Project. 
  Right click on Project ---> Add --> New item

2)You can see Dynamics365 Items. Here you can find all items irrespective of category.
                   (Or)
 You can go category wise and select Form

User interface-->Form (Give appropriate name for Form)


It automatically added into the form.The form structure like this in D365

You can see many new Override methods introduced in Form level. They are many some of the below screenshot


There is a concept called event handling introduced in D365 Forms.

You can see many new Override methods introduced in Form--> Datasource level also. They are many new methods, some of the below screenshot


You can see Events in form Datasource level also


Coming to the design part, then compared to previous version D365 design part very easy.
Previous version we have limited no.of templates, now we have many no.of patterns for form design.
In below of form page we can see preview for design, this is more easy for developer.


This just introduction, I will back with more information.

Happy Daxing.

14 Jul 2017

Compare UTCDATETIME with DATE in SSRS report + AX 2012

public boolean getFromDailog()
{
        ;
        fromDate    = clrSystemDateTime2UtcDateTime(dialogFromDate.value());
        todate      = clrSystemDateTime2UtcDateTime(dialogTodate.value() + 1);
        
        return true;
}

6 Jul 2017

Get all privileges,duties from Roles to Excel through code + AX 2012

static void getallrolesrespectdutiesandprivileges(Args _args)
{
    SecurityTaskEntryPoint  taskEntryPoint;
    SecurityRole            role;
    SecurityRoleTaskGrant   taskGrant;
    SecuritySubTask         subTask;
    SecurityTask            privilege;
    SecurityTask            securityTask;
    SecurableObject         securableObject;
    DictEnum                dictEnum;
    SysExcelApplication     application;
    SysExcelWorkbooks       workbooks;
    SysExcelWorkbook        workbook;
    SysExcelWorksheets      worksheets;
    SysExcelWorksheet       worksheet;
    SysExcelCells           cells;
    SysExcelCell            cell;
    int                     row;
    str                     privAOTName;
    str                     dutyAOTName;
    str                     privName;
    str                     dutyName;
    str                     entrName;
    str                     accessLevel;
    str                     menuItemType;
    FromTime                startTime = timeNow();
   
    // EXCEL Header
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    workbook = workbooks.add();
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(1);
    cells = worksheet.cells();
    cells.range('A:A').numberFormat('@');
    cell = cells.item(1,1);
    cell.value("Role AOT name");
    cell = cells.item(1,2);
    cell.value("Description");
    cell = cells.item(1,3);
    cell.value("Duty AOT name");
    cell = cells.item(1,4);
    cell.value("Description");
    cell = cells.item(1,5);
    cell.value("Privilidge AOT name");
    cell = cells.item(1,6);
    cell.value("Description");
    cell = cells.item(1,7);
    cell.value("Entry Point");
    cell = cells.item(1,8);
    cell.value("Type");
    cell = cells.item(1,9);
    cell.value("Access level");
    row = 1;
 
    while select taskEntryPoint
    join subTask
        where subTask.SecuritySubTask == taskEntryPoint.SecurityTask
    join taskGrant
        where taskGrant.SecurityTask == subTask.SecurityTask
    join role
        where role.RecId == taskGrant.SecurityRole      
    {
        menuItemType    = "";
        dutyAOTName     = "";
        dutyName        = "";
        privAOTName     = "";
        privName        = "";
         if (subTask.RecId)
        {
            switch (taskEntryPoint.PermissionGroup)
            {
                case AccessRight::View:
                    accessLevel = "Read";
                    break;
                case AccessRight::Edit:
                    accessLevel = "Update";
                    break;
                case AccessRight::Add:
                    accessLevel = "Create";
                    break;
                case AccessRight::Delete:
                    accessLevel = "Delete";
                    break;
                default:
                    accessLevel = "";
                    break;
            }
        }

        select privilege
            where privilege.RecId == taskGrant.SecurityTask
            && SecurityTaskType::Duty == privilege.Type;

        dutyAOTName = privilege.AotName;
        dutyName = privilege.Name;

        select privilege
            where privilege.RecId == subTask.SecuritySubTask
            && SecurityTaskType::Privilege == privilege.Type;

        privAOTName = privilege.AotName;
        privName = privilege.Name;

        select RecId, Type, Name from securableObject
        where securableObject.RecId == taskEntryPoint.EntryPoint && (securableObject.Type == SecurableType::MenuItemDisplay
            || securableObject.Type == SecurableType::MenuItemAction || securableObject.Type == SecurableType::MenuItemOutput);

        dictEnum = new DictEnum(enumNum(MenuItemType));
        menuItemType = dictEnum.index2Name(securableObject.Type);
       
        row++;
        cell = cells.item(row, 1);
        cell.value(role.AotName);
        cell = cells.item(row, 2);
        cell.value(role.Name);
        cell = cells.item(row, 3);
        cell.value(dutyAOTName);
        cell = cells.item(row, 4);
        cell.value(dutyName);
        cell = cells.item(row, 5);
        cell.value(privAOTName);
        cell = cells.item(row, 6);
        cell.value(privName);
        cell = cells.item(row, 7);
        cell.value(securableObject.Name);
        cell = cells.item(row, 8);
        cell.value(menuItemType);
        cell = cells.item(row, 9);
        cell.value(accessLevel);      
    }
   
    while select SecurityTask, SecurityRole from taskGrant
        join RecId, Type, AOTName from securitytask where securityTask.RecId == taskGrant.SecurityTask
                                                   && taskGrant.SecurityRole == taskGrant.SecurityRole
                                                   && securitytask.Type == SecurityTaskType::Privilege
        join securityTask, EntryPoint from taskEntryPoint  
                                     where taskEntryPoint.SecurityTask == securitytask.RecId

        {
            menuItemType    = "";
            dutyAOTName     = "";
            dutyName        = "";
            privAOTName     = "";
            privName        = "";

            select RecId, Type, Name from securableObject
                where securableObject.RecId == taskEntryPoint.EntryPoint &&
                (securableObject.Type   == SecurableType::MenuItemDisplay || securableObject.Type == SecurableType::MenuItemAction
                || securableObject.Type == SecurableType::MenuItemOutput);

            if(securableObject)
            {
                select privilege where privilege.RecId == securityTask.RecId
                        && SecurityTaskType::Privilege == privilege.Type;

                privAOTName = privilege.AotName;
                privName = privilege.Name;

                dictEnum = new DictEnum(enumNum(MenuItemType));
                menuItemType = dictEnum.index2Name(securableObject.Type);

                row++;
                cell = cells.item(row, 1);
                cell.value(role.AotName);
                cell = cells.item(row, 2);
                cell.value(role.Name);
                cell = cells.item(row, 3);
                cell.value(dutyAOTName);
                cell = cells.item(row, 4);
                cell.value(dutyName);
                cell = cells.item(row, 5);
                cell.value(privAOTName);
                cell = cells.item(row, 6);
                cell.value(privName);
                cell = cells.item(row, 7);
                cell.value(securableObject.Name);
                cell = cells.item(row, 8);
                cell.value(menuItemType);
                cell = cells.item(row, 9);
                cell.value(accessLevel);
            }
    }
    CodeAccessPermission::revertAssert();
    info(strFmt("Total time: %1", timeConsumed(startTime, timeNow())));
}

23 May 2017

Refresh or Ctrl + F5 issue + AX 2012

 FormRun         formRun;
    FormObjectSet   formObjSet;
    int             i;
    InventTable     linventTable;

  
    if (this.isFormDataSource())
    {
        formRun = this.dataSource().formRun();
        for (i=1; i<= formRun.dataSourceCount(); i++)
        {
            if (formRun.dataSource(i).cursor() is InventTable)
            {
                formObjSet = formRun.dataSource(i);
                linventTable = formObjSet.cursor() as InventTable;
                break;
            }
        }
        if (!linventTable)
        {
            linventTable = InventTable::find(this.ItemId, true);
        }
        if (linventTable)
        {
            if (formObjSet)
            {
                formObjSet.refresh();
                formObjSet.reread();
            }
        }
    }

3 May 2017

Number Sequence Error + AX 2012

 "System does not support setup 'continuous' of number sequence XXXXXX

Number selection is canceled."


ttsbegin;

custTable.AccountNum    =   NumberSeq::newGetNum(NumberSequenceReference::find(typeid2extendedTypeId(typeid(CustAccount)))).num();   // your code for number sequence

ttscommit;

1 Apr 2017

Attach files through X++ in AX 2012


Public void attachments()
{
    Filename            fileName  = @'D:\AX\Files.csv';
    DocuRef             docuRef,d
ocuRefLoc;
    DocuType            docuType;    
    HcmWorker           hcmWorker =      HcmWorker::findByPersonnelNumber('123456');
    DocuActionArchive   docuActionArchive;
    ;
    select docutype where docutype.ActionClassId == assNum(DocuActionArchive)                                                        &&  DocuType.TypeId == 'file' ;
      docuRef.RefRecId       = hcmWorker.RecId;
    docuRef.RefTableId     = hcmWorker.TableId;
    docuRef.RefCompanyId   = 'DAT';
    docuRef.TypeId         = docutype.TypeId;
    docuRef.insert();
    ttsBegin;
    select forupdate docuRefLoc where docuRefLoc.RecId ==  docuRef.RecId;
    docuActionArchive       = DocuAction::newDocuRef(docuRefLoc);
    docuActionArchive.add(docuRefLoc, fileName);
    ttsCommit;
}

7 Feb 2017

find Current Company Country Region Id + AX 2012

finding out the current company country region id.
LogisticsAddressCountryRegion::findByISOCode(SysCountryRegionCode::countryInfo(curext())).CountryRegionId.

7 Jan 2017

Get Mainaccount from ledgerDimension through X++ in AX 2012

public void Mainaccount(LedgerDimensionDefaultAccount   _LedgerDimensionDefaultAccount)
{

    DimensionAttributeValueCombination combination;
    MainAccount                         mainAccount;
    ;
    select DisplayValue from combination
                            where combination.recId == _LedgerDimensionDefaultAccount;

    select * from mainAccount where mainAccount.RecId == combination.MainAccount;
   Return mainAccount.MainAccountId;

}

14 Nov 2016

Users want to see Table name from personalization + ax 2012

Hi Folks,

Recently i got a requirement like Users want to see table name without development permissions.

Is it possible......what ever requirement we have to say yessssssssss only

From base i checked through debugger and i found some interesting facts.



1) Users unable to see Table name from personalization form.
2) Who have development permissions he only can able to see Table name from personalization form.

In SyssetupForm-- init()  restricting personalization permissions.

See above screen in that  when showDevInfo = True then only we can see personalization form.
When user become developer then only it will return TRUE otherwise false.

False means it will show any  Table name in  personalization form.

To overcome this i created new Table with 2 fields.
 1) userID
2)  Access (Enum- Noyes)

after this  i created new form for this.
Here logic is which users want to see personalization permissions we can add newly created form.
and i passed this  to personalization form.

If user is available in  this newly created form.
showDevInfo = True  problem solved.

7 Sept 2016

Create number sequence in D365 FO

Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...