Popular Posts

Tuesday 19 July 2011

Date Calculation

Date Calculation :

static void DateCalcu(Args _args)
{
    TransDate   fromDate,toDate;
    int         reqDays;
    ;
  
    fromDate    = mkdate(01,07,2011);
    toDate      = mkdate(19,06,2011);
  
    if(fromDate && (toDate > fromdate))
    {
        reqDays = todate - fromDate;
    }
    else
    {
        throw error(strfmt("To-date %1 must be greater than from-date %2",todate,fromdate));
    }
    info(strfmt("%1",reqDays));
}

Thursday 14 July 2011

to filtering form by the enum values(which is n't shown in form)

suppose they are 3 field in enum one value is shown in form and another form is used in another form .we put the filter in datasource-->init method write the following code.
this.query().dataSourceTable(tablenum(inventtable)).addRange(fieldnum(inventtable,lltype)).value(enum2str(lltype::Both));

find and exit methods in tables

Exist Method:
static boolean exist(ItemId  itemId)--->this is key which is primary
{
    return itemId && (select RecId from inventTable -->table name
                index hint ItemIdx--->index name in table
                where inventTable.ItemId == itemId
                ).RecId != 0;
}
Find Method:
static InventTable find(ItemId      itemId,
                        boolean    update = false--->to define how many primarykeys in table )
{
    InventTable  inventTable;
    ;
    inventTable.selectForUpdate(update);
    if (itemId)
    {
        select firstonly inventTable-->table name
            index hint ItemIdx-->index name
            where inventTable.ItemId == itemId;
    }
    return inventTable;
}

Wednesday 6 July 2011

display records from different company accounts in one form

display records from different company accounts in one form

One of the previous posts on this blog discussed getting records from different company accounts with one select statement. For this, the crossCompany keyword is used.
Now we'll do something similar, but this time we'll display the records in a form. And the good news is, it's really easy. All ya have to do, is set a property on the datasource of the form.

You can use the crossCompanyAutoQuery property, located on the forms datasource. Standard value is 'No', so set it to 'Yes'

control:: enum on forms


control:: enum on forms

A somewhat non-intuitive way of accessing controls on a form is using a built in enum named ‘control’. This enum automatically contains all controls of you form (tabs, buttons, etc), and you can reference them by name.
So, if for example your button is called ‘ButtonFunctions’, you can set the property ‘enabled’ to false like this:
element.control (Control::ButtonFunctions).enabled (false);
The main advantage here is that you don’t have to set the property autodeclaration to yes

Rename an AX company on SQL


Rename an AX company on SQL
A while ago, I talked about deleting an AX company on SQL, but of course, you can also use the sp_MSforeachtable stored procedure to rename a company (= change the DataAreaId of a company).
In the next example, I rename CEE to CEA:
exec sp_MSforeachtable ‘update? set DataAreaID = "CEA" where? DataAreaID = "CEE"'

UPDATE DataArea SET ID = 'CEA' WHERE DataArea.ID = 'CEE'
UPDATE CompanyDomainList SET CompanyID = 'CEA' WHERE CompanyID = 'CEE'

Ax Application File Extence


Application file extensions

Dynamics AX uses a lot of file extensions, but luckily, there is logic to them, so you can easily identify their purpose.
Most of these files are located in the application folder (AX 2009):
C:\Program Files\Microsoft Dynamics AX\50\Application\Appl\ [your_application]
The extensions have 3 characters:
The first character indicates the owner of the file:
a: application
k: kernel
The second character indicates the content of the file:
l: label
o: object
t: text
d: developer documentation
h: help
And the third character indicates the type of file:
d: data
i: index
c: cache
t: temporary
Using this logic, we can easily name all file extensions, and understand their purpose.
In the application folder:
ALD extension: Application Label Data files
These files contain the labels and label comments for a specific language of a label file.
ALC extension: Application Label Cache files.
These files contain the application label cache. These files can be deleted when the AOS is stopped.
ALI extension: Application Label Index files.
The .ali files contain an index to the .ald files. These files can be deleted when the AOS is stopped.
ALT extension: Application Label Temporary files.
These files contain new labels before they are committed to the .ald file.
AOI extension: Application Object Index file
The AOI file contains an index to the AOD files. You can delete this file when the AOS is stopped. Be sure to delete this when you have copied layers from one AX installation to another.
ADD extension: Application Developer Documentation Data files.
These files contain the documentation that is found under the Application Developer Documentation node. These files are localized, just like label files.
ADI extension: Application Developer Documentation Index files.
This is the index to the ADD file.
AHD extension: Application Help Data files
The AHD file contains the documentation aimed at the end user. In the AOT, this is found in the “Application Documentation” node.
AHI extension: Application Help Index files.
This is the index to the AHD file.
AOD extension: Application Object Data file.
This is the ‘AX layer file’; each of these files represents one layer.
KHD extension: Kernel Help Documentation files.
These files contain the kernel help documentation you can find in the AOT in the tree node System Documentation.
KHI extension: Kernel Help Index files

The KHI file is the index to the Kernel Help file.
Located in Server/bin:
KTD extension: Kernel Text Data file.
This file contains system text strings. These are used in the interface of AX and for system messages.
KTI extension: Kernel Text Index file.
This is the index to the KTD file.

Filter On lookups using relations & method


Filter lookup based on enums using relations :
Method: 1

 

Method: 2

Remove the EDT on ItemId it filters automatically based on ItemType
PerformLookup:
Write this method in Table:
Static FormRun itemRecruitingIdLookup(FormRun lookupFormRun, FormControl _ctrl)
{
            FormDataSource          formDataSource;
            Query                   formquery;
            ;
    formDataSource  = lookupFormRun.objectSet();
    formquery       = formDataSource.query();
formquery.dataSourceNo (1).addRange (fieldnum (InventTable, ItemType)).value (queryValue (ItemType::BOM));
    return lookupFormRun;
}
In form datasource field method write the following code:
public void performFormLookup(FormRun _p1, FormControl _formControl)
{
    Super (HRMApplication::hrmRecruitingIdLookup (_p1), _formControl);
}