25 Aralık 2014 Perşembe

AX 2012 - Consume web service with sample turkish citizen ID check

I used a blog when developing this sample. You can download to ready use XPO from there .

1- Create a new  Class Library type C# project at Visual Studio.

2- Press right click at project name, select Add service reference and write https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL to Address, write Sorgula to Namespace and press GO so service reference will be shown.

3- Add your project to AOT with Add to AOT .

4- Go to project properties and make

Debug Target = No
Deploy to Client = Yes
Deploy to EP = No
Deploy to Server = Yes
Deploy to SSRS = No 

5. Deploy project and down all AX clients. If you don't down all clients at deploy, deploy will fail accoring to blog writer.

This is my sample job:

//Metin Emre, 2.10.2014
static void TCIDTest(Args _args)
    CLRObject                             clientType;
    TCKimlik.Sorgula.KPSPublicSoapClient  cl;
    System.Exception                      ex;
    boolean                               s,erOccured;
    System.Exception                      e;
    str                                   ret;

    new InteropPermission(InteropKind::ClrInterop).assert();

        clientType = CLRInterop::getType("TCKimlik.Sorgula.KPSPublicSoapClient");
        cl = AifUtil::createServiceClient(clientType);
        s = cl.TCKimlikNoDogrula(11111111111,"METİN","EMRE",1999);
        ret = Ex.ToString();
        if (!strScan(ret,"Not a valid citizen ID",1,strLen(Ret)))
            erOccured = true;
    if (!erOccured)

11111111111 is citizen ID, name and surname after citizen ID and the last born year. If all these are correct, returns true else false.

29 Eylül 2014 Pazartesi

AX 2012 - R3 Installation

In first check  minimum system requirements . MS-SQL collate doesn't installed as turkish. With turkish like SAP and Oracle you'll have problems about "i" letter of turkish, after AX 2012 install, at database sync, installation will fail.
I used Dilip's Blog for installation instead of Microsoft's long and complex white paper. Installation of AX 2012 is so easy of it's mine change. :)

In first Active Directory should be installed. There are plenty of pages about AD installation at Google.

I just used basic AX 2012 like Dilip's, let SSRS etc. installation later. AX 2012 setup gives prerequisities links and configures some of prerequisities automatically. I didn't faced any problem at installation.

After installation I upload demo data again from a  blog page . Demo installation was harder than AX 2012 installation.

I installed SQL Server SSRS add-in and configured look from a blog . Anyway for developing SSRS reports (Doesn't require for deploy) don't forget install Business Intelligence Development Studio from SQL Server Setup. SSRS configure was so easy; in order run Service account, Web service URL, Database, Report Manager URL tabs with defaults was enough.

Again I used  another Dilip page for SSRS install. I haven't got any trouble and didn't need Dilip's manual complete way for install, reports deployed smootly. :)

26 Eylül 2014 Cuma

AX 2012 - If batch jobs cannot start?

If you look up Home->Inquiries->Batch jobs->My batch jobs and see batch jobs don't start.

Go System administration->Setup->System->Server configuration and check there is a record at Batch server schedule with proper time gap (00:00 -23:59) and be careful about Maximum batch threads value bigger than zero.

Also problem maybe about there is no attached server to batch group :
Administration -> setup -> Batch Groups
Find empty batch group and go Batch Servers tab, look for Selected server field has correct server value.

15 Eylül 2014 Pazartesi

AX 2012 - Create a new financial dimension which related a table(s)

I found the easy way that the way from a blog which referred Microsoft'un related white paper:

1-Duplicate one of views from AOT which beginned DimAttribute and new views name should be begin same DimAttribute word.
2. Main datasource name should be BackingEntity unrelated what name used with original table name.
3. All field names of view should be like these whatever original names:
Key - data source tables Surrogate key field. Like RecId...
Value - data source tables primary key . Like AccountNum...
Name - Description field. Like Description or CustomerName...

There are two ways to use this new dimension implementation:

AOS restart




11 Eylül 2014 Perşembe

AX 2012 - Get an individual dimension value from a LedgerDimension value

I used a data model about ledger dimension from a blog when I create this page. Unfortunately I couldn't understand code written at that blog and wrote this code:

 DimensionDefault                        d =  5637183219;
    DimensionAttributeValueCombination      dimensionAttributeValueCombination;
    DimensionAttributeValueGroupCombination dimensionAttributeValueGroupCombination;
    DimensionAttributeValueGroup            dimensionAttributeValueGroup;
    DimensionAttributeLevelValue            dimensionAttributeLevelValue;
    DimensionAttributeValue                 dimensionAttributeValue;
    DimensionAttribute                      dimensionAttribute;
    select dimensionAttributeValueCombination
            where dimensionAttributeValueCombination.RecId == d
        join dimensionAttributeValueGroupCombination
            where dimensionAttributeValueGroupCombination.DimensionAttributeValueCombination ==
        join dimensionAttributeValueGroup
            where dimensionAttributeValueGroup.RecId == dimensionAttributeValueGroupCombination.DimensionAttributeValueGroup
        join dimensionAttributeLevelValue
            where dimensionAttributeLevelValue.DimensionAttributeValueGroup == dimensionAttributeValueGroup.RecId
        join dimensionAttributeValue
            where dimensionAttributeValue.RecId == dimensionAttributeLevelValue.DimensionAttributeValue
        join dimensionAttribute
            where dimensionAttribute.RecId == dimensionAttributeValue.DimensionAttribute &&
                  DimensionAttribute.Name == "Project";

The code at up doesn't worked for PurchTable defaultDimension field.
I got this code from Andesoft'un web site :

 DimensionDefault                        d =  5637169331;
    DimensionAttributeValueSet  dimAttrValueSet;
    DimensionAttributeValueSetItem  dimAttrValueSetItem;
    DimensionAttributeValue         dimAttrValue;
    DimensionAttribute          dimAttr;
    Common      dimensionValueEntity;
    DimensionValue  dimensionValue;
    DimensionAliasName  dimensionName;
    dimAttrValueSet = DimensionAttributeValueSet::find(D);
    while select dimAttrValueSetItem
        where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
        dimAttrValue = DimensionAttributeValue::find(dimAttrValueSetItem.DimensionAttributeValue);
        dimAttr = DimensionAttribute::find(DimAttrValue.DimensionAttribute);
        dimensionvalueentity = DimensionDefaultingControllerBase::findBackingEntityInstance(
        dimensionvalue = dimattrvalue.getValue();
        info(strFmt("%1 %2",Dimensionvalue, DimAttr.Name));

10 Eylül 2014 Çarşamba

AX 2012 - Get an individual dimension value from a DefaultDimension

I used another blogs code when writing this code:

   DimensionAttributeValueSetStorage  dimStorage; 
   Counter               i; 
   DimensionAttribute         dimAttributeCostCenter; 
   DimensionAttributeValue       dimAttributeValue; 
   DimensionDefault         d =  5637168596;
   dimStorage = DimensionAttributeValueSetStorage::find(d); 

AX 2012 - Add a new dimension value to Default dimension

I wrote this code from one of Eyüp Tezar's code:

DimensionDefault DefDim;
DimensionAttribute                  dimensionAttribute;
DimensionAttributeValue             newValue;
DimensionAttributeValueSetStorage   dimensionStorage;

DefDim = mytable.Defaultdimension;

dimensionAttribute = DimensionAttribute::find(myDimRecid);

newValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,

dimensionStorage = DimensionAttributeValueSetStorage::find(DefDim);

DefDim = dimensionStorage.save();

//------------------- another dimension ------------------------

dimensionAttribute = DimensionAttribute::findbyName("Project");

newValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,

dimensionStorage = DimensionAttributeValueSetStorage::find(DefDim);

DefDim = dimensionStorage.save();

8 Eylül 2014 Pazartesi

AX 2012 - New taxtrans table structure

Taxtrans table structure changed with AX 2012. There's a good white paper of Microsoft about this. There's a sample join below:

    select generalJournalAccountEntry
            join generalJournalEntry
        where generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry &&
              generalJournalEntry.RecId == _RecId
            join subledgerVoucherGeneralJournalEntry
        where subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalEntry.RecId
            join dimensionAttributeValueCombination
        where dimensionAttributeValueCombination.RecId == generalJournalAccountEntry.LedgerDimension
            join mainAccount
        where mainAccount.RecId == dimensionAttributeValueCombination.MainAccount;

AX 2012 - Where's LedgerTrans?

LedgerTrans gone with AX 2012 and came some new tables. You have to join these tables. There's a good  white paper of Microsoft's about this issue. Some fields renamed and/or moved different tables, all of these explained at this white paper. There's a sample join below:

select generalJournalAccountEntry
            join generalJournalEntry
        where generalJournalEntry.RecId == generalJournalAccountEntry.GeneralJournalEntry &&
              generalJournalEntry.AccountingDate  >=  beginDate && generalJournalEntry.AccountingDate <= endDate
            join subledgerVoucherGeneralJournalEntry
        where subledgerVoucherGeneralJournalEntry.GeneralJournalEntry == generalJournalEntry.RecId
            join dimensionAttributeValueCombination
        where dimensionAttributeValueCombination.RecId == generalJournalAccountEntry.LedgerDimension
        join mainAccount
        where mainAccount.RecId == dimensionAttributeValueCombination.MainAccount &&
              mainAccount.MainAccountId == myAccount

3 Eylül 2014 Çarşamba

AX 2012 - Set voucher to LedgerJournalTrans table

When use AXLedgerJournalTrans class, voucher set as automatically. But if you add record directly to table you have to set voucher:

numberSeq   = numberSeq::newGetVoucherFromCode(NumberSequenceTable::find(ledgerJournalTable.ledgerJournalName().NumberSequenceTable).NumberSequence);
 LedgerJournalTrans.Voucher     = numberSeq.voucher();

2 Eylül 2014 Salı

AX 2012 - Add splitter to form

It's more easy to add splitter control to AX 2012 than 2009. I'll tell horizontal splitter:

Add a group for top part of form. I named it as Hsplitter. Set AutoDeclaration = Yes and  Style = SplitterHorizontalContainer. Add another group for down part of form. Give a name to top group. I named it as TopGroup, also set AutoDeclaration = Yes for this group too. Make bottom groups Height as Column Height. Splitter group should be betwen of other two.

Add this line to form's classDeclaration:

SysFormSplitter_Y                       HorizontalSplitter;

If splitter will be vertical should be SysFormSplitter_X.

Add this line to form's init method:

HorizontalSplitter = new SysFormSplitter_Y(HSplitter,TopGroup, element);

If vertical, should be new SysFormSplitter_X ...

That's all...

8 Ağustos 2014 Cuma

AX 2012 - CIL Error 351

Sometimes you can get this error:

Description: CIL generation: The given key was not present in the dictionary.

Path: \XppIL

Line: 1

Method/Property: XppIL

Error: Err:351

Sync DataDictionary and remove all errors at AOT.
Down AOS. Delete all files from this directory except subfolders:

C:\Program Files\Microsoft Dynamics AX\60\Server\AX2012R2_Dev\bin\XppIL

5 Ağustos 2014 Salı

AX 2012 - Add defaultdimension control to form

You can look for LedgerJournalTable form for how to do.
Add a relation with DimensionAttributeValueSet table's RecId  field for which field added from DimensionDefault EDT.

Add a tab page named tabFinancialDimensions and change properties like below:

AutoDeclaration = true
caption = @SYS101181
HideIfEmpty = No
NeedPermission = Manual

Add this line to forms classDeclaration method:

DimensionDefaultingController       dimensionDefaultingController;

Add this code part to forms init method:

public void init()

   boolean allowEdit = true;
    dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(false, true, allowEdit, 0, this, tabFinancialDimensions, "@SYS101181");
    dimensionDefaultingController.parmAttributeValueSetDataSource(MyTable_ds, fieldStr(MyTable, DefaultDimension));

Add this method to tab page:

public void pageActivated()

Update table data source methods like below:

public void delete()

public void write()

public int active()
    int ret;

    ret = super();
    return ret;

4 Ağustos 2014 Pazartesi

AX 2012 - SSRS How to suppress zero as blank?

Put this instead of put field (At this time PurchPrice) itself:

=IIF(Fields!PurchPrice.Value = 0 ,"",Fields!PurchPrice.Value)

17 Temmuz 2014 Perşembe

AX 2012 - When Developing SSRS Report, if Visual Studio Table Window Disappears?

View->Report Data

AX 2012 - My New Field's Value Disappearing when Editing VendInvoiceInfoTable

I add a new field to VendInvoiceInfoTable When try to edit with VendEditInvoice form I saw my new field's value is empty. After a long research I found out Axapta copy source record to another record and edit this new record. Meanwhile Axapta skips my new field. Axapta uses table method copyFromHeader while copying. Add my new line:

    this.VendorRequestedWorkerEmail = _header.VendorRequestedWorkerEmail;
    //my new field
    this.myNewField     = _header.

Problem overed. Same method valid for related VendInvoiceInfoLine table too.

AX - 2012 What Comes Instead of TypeId?

You'll see TypeId doesn't work at AX 2012. Instead of that AX 2012'de you may use EnumStr for enums and diğer ExtendedTypeStr for other data types.

11 Temmuz 2014 Cuma

AX 2012 - Send marked records to SSRS RDP Report

SSRS DP Class don't accept table or container data types as parm method. I searched at forums and saw str data type adviced. But I think this's not best approach. At last learned best way already in standard AX SSRS reports. At this link there's a PDF file tells look for check report. I generated this report with look form ChequeDP and ChequeController classes:

Controller class:

class declaration:

class myController extends SrsReportRunController
   myTMPTable   myTMPTable;

public static void main(Args _args)
    SysLastValue    SysLastValue;
    myController controller = new myController();

protected void prePromptModifyContract()

    SrsTmpTblMarshallerContract contract = this.parmReportContract().parmRdpContract() as SrsTmpTblMarshallerContract;

    new SRSReportRunPermission().assert();


public void init()
    FormDataSource      ds;
    TransDate           transDate;
    VendTrans           vendTrans;

    if (!this.parmArgs()             ||
        !this.parmArgs().record()    ||
        this.parmArgs().dataset() != tableNum(VendTrans))
        throw error("Report should be call with correct parameter!..");

    ds = this.parmArgs().record().dataSource();

    vendTrans = ds.getFirst(1);
    transDate = vendTrans.transDate;
    PaymentReceipt.VendAccount = vendTrans.AccountNum;

    for (vendTrans = ds.getFirst(1); vendTrans != null; vendTrans = ds.getNext())
        myTMPTable.Date             = vendTrans.TransDate;


DP Class:

// <ETG - memre > GN:   T: 11.07.2014 A:
public class mpDP extends SRSReportDataProviderBase
    myTMPTAble myTMPTable;

private void initTmpTable()
    SrsTmpTblMarshallerContract contract = this.parmDataContract() as SrsTmpTblMarshallerContract;

    new SRSReportRunPermission().assert();

    myTMPTable = SRSTmpTblMarshaller::getTmpTbl(contract.parmTmpTableDataRecId());


public void processReport()

    CompanyInfo                 Company;
    VendTable                   vendTable;
    AmountMST                   amount;
    TempStr                     NumtoTxt;
    LedgerJournalTrans          LedgerTrans;



25 Haziran 2014 Çarşamba

AX 2012 - Refresh form data

A Subroutine of you called refreshs data. Form's data doesn't refresh. To solve this issue you have to call first research and then refresh. Research doesn't broke your query filters and if you call it with true parameter it goes to current record after refresh:


If your subroutine is a SysOperation class and your screen doesn't refresh anyway, don't forget add this to your controller class:


If you don't, your research and refresh methods run before your classes completed it's job.

24 Haziran 2014 Salı

AX 2012 - Default dimension

public static DimensionDefault CreateDefaultDim(Container _a,Container _v)

    DimensionAttributeValueSetStorage   valueSetStorage = new DimensionAttributeValueSetStorage();
    DimensionDefault                               result;
    int                                                      i;
    DimensionAttribute                            dimensionAttribute;
    DimensionAttributeValue                   dimensionAttributeValue;
    //_attr is dimension name in table DimensionAttribute
    container               conAttr  =  _a;
    container               conValue =   _v;
    boolean                 _createIfNotFound = true;
    str                     dimValue;

    for (i = 1; i <= conLen(conAttr); i++)
        dimensionAttribute = dimensionAttribute::findByName(conPeek(conAttr,i));

        if (dimensionAttribute.RecId == 0)

        dimValue = conPeek(conValue,i);

        if (dimValue != "")
            // _createIfNotFound is "true". A dimensionAttributeValue record will be created if not found.

            // Add the dimensionAttibuteValue to the default dimension
    result = valueSetStorage.save();

    return result;

Sample usage:

LedgerJournalTrans.DefaultDimension = MyUtility::CreateDefaultDim("[Contract],[Project]","[0001],[MyBigProject]")

If you get Unable to return DimensionAttributeValue record for ... error than you try create a dimension combination values unavailable in system.

20 Haziran 2014 Cuma

AX 2012 - Query; set Date value with strfmt.

If you want to set date value with strfmr for Axapta queries you have to use Date2StrXpp function:

QBR2.value(strFmt(' ( TransDate >= %1 )' , Date2StrXpp(TransDate) ));

17 Haziran 2014 Salı

AX 2012 Add validate method, groupping and labeling parameters with RDP class

Class Declaration:

    SysOperationGroupAttribute("DateGroup", "Date Range", "1", FormArrangeMethod::Vertical),
    SysOperationGroupAttribute("Other", "Other Filters", "1", FormArrangeMethod::Vertical)
class myContract implements SysOperationValidatable


Parm method:

public StartDate parmStartDate(StartDate _StartDate = startDate)
   startDate = _StartDate;
   return StartDate;

Validate method:

public boolean validate()
    boolean isValid = true;
    if ( !endDate || !StartDate)
        isValid = checkfailed("You have to enter first/last dates!..");

    return isValid;

AX 2012 Add Query to SSRS report when developing with RDP

Add query attribute to data provider class:

    SRSReportQueryAttribute (querystr(Cust)),
class myReportDP extends SRSReportDataProviderBase

Get query like this:

public void processReport()
    QueryRun                    qRun;
    Query                       query;

    query = this.parmQuery();

Do not forget make Dynamics Filter property to true at SSRS report Dataset if you want to see select query button.

AX 2012 - Sysoperation class sample

Contract Class:
classDeclaration method:

class myTestContract
    TransDate       transDate;
    str             packedQuery;
    LedgerJournalId JournalId;

Other methods:
//------ for get Query  -------------
public Query getQuery()
    return new Query(SysOperationHelper::base64Decode(packedQuery));

//---------- parm method sample --------------
, SysOperationControlVisibilityAttribute(false)]
public LedgerJournalId parmJournalId(LedgerJournalId _JournalId = JournalId)
    JournalId = _JournalId;

    return JournalId;

//--------------------- call query with parmQuery  ----------------
    AifQueryTypeAttribute('_packedQuery', querystr(myQuery))
public str parmQuery(str _packedQuery = packedQuery)
    packedQuery = _packedQuery;
    return packedQuery;

//-------------- send query with SetQuery -----------------------
public void setQuery(Query _query)
    packedQuery = SysOperationHelper::base64Encode(_query.pack());

DataService Class:

ClassDeclaration metodu:
class myDataService

Batch job method:

public void Go(myContract _contract)
    QueryRun                            qRun;
    Query                               query;
    QueryBuildDataSource                QBDS;
    QueryBuildRange                     QBR,QBR2;
    CustTable               CustTable;
    LedgerJournalId                     JournalId;
    TransDate                           PaymDate;
    LedgerJournalTrans                  journalTrans;

    JournalId = _contract.parmJournalId();

    query = _contract.getQuery();
    QBDS = query.dataSourceTable(tablenum(CustTable));
    QBR = QBDS.findRange(fieldnum(CustTable,CustAccount));
    if (!QBR)
        QBR = QBDS.addRange(fieldnum(CustTable,CustAccount));

    qRun = new QueryRun(query);

        CustTable = qRun.get(tableNum(CustTable));

Controller Class:
class declaration:

class MyController extends SysOperationServiceController

public static MyController newFromArgs(Args _args)
    MyController    controller;
    MyContract      contract;
    LedgerJournalTable             LedgerJournalTable;

    if ( !_args || !_args.caller() )
        throw error("This class needs parameter!..");

    ledgerJournalTable = _args.caller().ledgerJournalTable();
    controller = new ETGVendAdvanceReqController();


    contract = Controller.getDataContractObject("_contract");

    return Controller;

public static void main(Args _args)
    MyController controller;

    controller = MyController::newFromArgs(_args);


Menu item parameters:

Object - MyController
ObjectType - class
Parameters - MyDataService.Go 

AX 2012 - How to read/write Vendor/Customer to LedgerJournalTrans table?

This information store in ledgerDimension field. When writing:

LedgerJournalTrans.LedgerDimension    = DimensionStorage::getDynamicAccount(myVendAccount, LedgerJournalACType::Vend);

When reading you can look up for AccountDisplay or accountNameFind methods or:


CustTable::findByLedgerDimension(ledgerJournalTrans.LedgerDimension)                                                     VendTable::findByLedgerDimension(ledgerJournalTrans.LedgerDimension)

4 Nisan 2014 Cuma

AX 2012 - Generate RDP (Report Data Provider)

Data Provider class:

------------Class Declaration-------------------
class myCustInvoicePrintDP extends SRSReportDataProviderbase
    CustInvoicePrintTMP      InvoicePrint;
    CustInvoicePrintTransTMP InvoicePrintTrans;
    CustInvoicePrintTaxTMP   InvoicePrintTax;
    CustInvoicePrintFootTMP  InvoicePrintFoot;

    RecId                       RecId;

-----------------Table methods for SSRS---------------------------
public CustInvoicePrintTMP getCustInvoicePrint()
    select * from InvoicePrint;
    return InvoicePrint;

public CustInvoicePrintTransTMP getCustInvoicePrintTrans()
    select * from InvoicePrintTrans;
    return InvoicePrintTrans;

------------------GetParameter method--------------------------------
private void getReportParameters()
    myCustInvoicePrintContract Contract = this.parmDataContract();

    if (Contract)
        RecId   = Contract.parmRecordId();

------------------- processReport method where data filled--------
public void processReport()
    CustInvoiceJour         InvoiceJour;
    CustInvoiceTrans        InvoiceTrans;
    TaxTrans                taxTrans;
    TaxOnItem               taxOnItem;
    TaxGroupData            taxGroupData;
    AmountMST               Tax;

    InvoiceJour = CustInvoiceJour::findRecId(RecId);
    InvoicePrint.InvoiceDate    = InvoiceJour.InvoiceDate;
    InvoicePrint.InvoiceName    = InvoiceJour.invoiceName();
    InvoicePrint.TaxOfficeName_TR   = CustTable::find(InvoiceJour.InvoiceAccount).TaxOfficeName_TR;
    while select InvoiceTrans where
        InvoiceTrans.SalesId == InvoiceJour.SalesId && InvoiceTrans.InvoiceId == InvoiceJour.InvoiceId &&
        InvoiceTrans.InvoiceDate == InvoiceJour.InvoiceDate && InvoiceTrans.numberSequenceGroup == InvoiceJour.numberSequenceGroup
        select taxOnItem
                where taxOnItem.TaxItemGroup == InvoiceTrans.TaxItemGroup
            join taxGroupData
                where taxGroupData.TaxCode == taxOnItem.TaxCode &&
                      taxGroupData.TaxGroup == InvoiceTrans.TaxGroup;
        InvoicePrintTrans.TaxValue          = TaxData::find(TaxOnItem.TaxCode, InvoiceTrans.InvoiceDate, 0).TaxValue;
        InvoicePrintTrans.Qty               = InvoiceTrans.Qty;
        Tax = Tax::calcTaxAmount(InvoiceTrans.TaxGroup,taxOnItem.TaxItemGroup,InvoiceTrans.InvoiceDate,

Controller class:

--------------Class Declaration------------------
class myCustInvoicePrintController extends SrsReportRunController
    myCustInvoicePrintContract    contract;
    CustInvoiceJour           custInvoiceJour;

Get parameter
protected void prePromptModifyContract()
    if (this.parmArgs()             &&
        this.parmArgs().record()    &&
        this.parmArgs().dataset() == tableNum(CustInvoiceJour))
        custInvoiceJour = this.parmArgs().record();

    if (!Contract)
        Contract = this.parmReportContract().parmRdpContract();



public static myCustInvoicePrintController construct(Args _args)
    myCustInvoicePrintController controller = new myCustInvoicePrintController();
    return controller;

public static void main(Args _args)
    SysLastValue    SysLastValue;
    myCustInvoicePrintController controller = new myCustInvoicePrintController();

    controller.parmShowDialog(false); //don't show dialog at screen

Contract class:
---------------class declaration---------------------------

class myCustInvoicePrintContract
    RecId recordId;
Get parameter
public recId parmRecordId(recId _recordId = recordId)
   recordId = _recordId;
   return recordId;

10 Mart 2014 Pazartesi

AXAPTA - Find VAT rate and amount at document lines

while select InvoiceTrans where
        InvoiceTrans.SalesId == InvoiceJour.SalesId && InvoiceTrans.InvoiceId == InvoiceJour.InvoiceId &&
        InvoiceTrans.InvoiceDate == InvoiceJour.InvoiceDate && InvoiceTrans.numberSequenceGroup == InvoiceJour.numberSequenceGroup
        InvoicePrintTrans.Name  = InvoiceTrans.Name;
        select taxOnItem
                where taxOnItem.TaxItemGroup == InvoiceTrans.TaxItemGroup
            join taxGroupData
                where taxGroupData.TaxCode == taxOnItem.TaxCode &&
                      taxGroupData.TaxGroup == InvoiceTrans.TaxGroup;
        TaxValue  = TaxData::find(TaxOnItem.TaxCode, InvoiceTrans.InvoiceDate, 0).TaxValue;
Tax = Tax::calcTaxAmount(InvoiceTrans.TaxGroup,taxOnItem.TaxItemGroup,InvoiceTrans.InvoiceDate,

        info(strFmt("VAT rate %1 VAT amount",TaxValue,Tax));

26 Şubat 2014 Çarşamba

AXAPTA - Call a class extended from another with name string

There are three ways:

1- classFactory.createClass(className2Id('MyClass'))

2- test1  test;
    DictClass d;

    d = new DictClass(className2Id("test1"));
    test = d.makeObject(222);

3. Just for AX 2012 için extension framework . I'll look up this later.

4 Şubat 2014 Salı

AX 2012 - Company logo

mylogo = FormLetter::companyLogo();

AX 2012 - Test RDP class at Axapta side

How do you test your RDP classes developed for SSRS reports at AX side?

DGHCreditDetailsDP  dp = new DGHCreditDetailsDP();
DGHCreditDetailsDC  dc = new DGHCreditDetailsDC();

Query q;


q = dp.parmQuery();

         q.dataSourceTable(tableNum(BankAccountTrans)).addRange(Fieldnum(BankAccountTrans,accountid)).value("102 02 034 002");


6 Ocak 2014 Pazartesi

AX 2012 - Create SSRS report PDF output

I got help from Martin Drab's blog for create PDF with AX 2012:

void CreatePDF(Str60 _Subject,Notes _Body)
MYReportPurchController          controller;
MYReportPurchContract            rdpContract = new MyReportPurchContract();
SRSPrintDestinationSettings settings;
Args                        args = new args();
str                         fileName;

controller = MYReportPurchController::construct(args);
// Define report and report design to use
// Use execution mode appropriate to your situation
// Suppress report dialog

// Explicitly provide all required parameters
// Change print settings as needed
settings = controller.parmReportContract().parmPrintSettings();


  fileName = WinApi::getTempPath() +this.PurchOrderDocNum+".PDF";
// Execute the report

Or send selected records to PDF by RDP report:
SMAServiceOrderTable        serviceOrder;
    MultiSelectionHelper        helper;
    FormRun                     caller = _args.caller();
    FormDataSource              SMAServiceOrderTable_DS;
    SRSPrintDestinationSettings settings;
    ETGServiceReportContract    contract = new ETGServiceReportContract();
    SrsReportRunController      controller;
    Filename                    fileName;
    int                         counter;
    SysMailer                   mailer = new SysMailer();
    SysEmailParameters          parameters = SysEmailParameters::find();
    Dialog                      dialog;
    DialogField                 field;
    Email                       email;

    dialog = new Dialog("Servis Raporu Gönderme");
    field = dialog.addField(ExtendedTypeStr(email));

    if (!dialog.closedOK())
    email = field.value();
    if (email == "")
        throw error("Bir mail adresi girmelisiniz!..");

    SMAServiceOrderTable_DS = caller.dataSource();
    helper = MultiSelectionHelper::createFromCaller(caller);
    if (parameters.SMTPRelayServerName)
    mailer.htmlBody('<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9">Sayın Yetkili,<br><br> Servis raporu kopyanız ektedir.<br><br>Saygılarımızla,<br><br><br>Sinbo');
    mailer.subject('Sinbo Servis Raporu');

    serviceOrder = helper.getFirst();

        controller = new SrsReportRunController();
        controller.parmReportName(ssrsReportStr(ETGServiceReport, Report));
        contract = controller.parmReportContract().parmRdpContract();

        fileName = WinApi::getTempPath() + strFmt("Servis Raporu %1.PDF",counter);
        settings = controller.parmReportContract().parmPrintSettings();
        serviceOrder = helper.getNext();
    if (counter == 0)


AXAPTA - Send email

private void SendMail2(str _FileName,Str60 _Subject,Notes _Body)

   str Toaddress;
   System.Net.Mail.MailMessage Msg =  new System.Net.Mail.MailMessage();
   System.Net.Mail.MailAddress fromMail;
   System.Net.Mail.MailAddressCollection toadrr;
   System.Net.Mail.SmtpClient smCL = new System.Net.Mail.SmtpClient();
   System.Net.NetworkCredential credential;
   str          bodygrd,sSmtpServer;
   CLRObject   exc;
   CLRObject   innerExc;
   CLRObject   clrExcMessage;
   str         strError;
   SysEmailParameters EmailParm;
   str pass;
   System.Net.Mail.AttachmentCollection  mailAttachementCollection;
   System.Net.Mail.Attachment            mailAttachment;


    EmailParm = SysEmailParameters::find();
    pass = SysEmailParameters::password();
    credential = new System.Net.NetworkCredential(EmailParm.SMTPUserName,pass);
    fromMail = new System.Net.Mail.MailAddress(EmailParm.SMTPUserName);
    new InteropPermission(InteropKind::ClrInterop).assert();
    toadrr = Msg.get_To();
    toadrr.Add(new System.Net.Mail.MailAddress(toaddress));
    sSmtpServer =  EmailParm.SMTPRelayServerName;
    mailAttachementCollection = msg.get_Attachments();
        mailAttachment = new System.Net.Mail.Attachment(_fileName);
  }     catch( Exception::CLRError )
                        exc = CLRInterop::getLastException();
                        if( exc )
                           clrExcMessage = exc.get_Message();
                           innerExc = exc.get_InnerException();
                           while(innerExc != null)
                              clrExcMessage = innerExc.get_Message();
                              innerExc = innerExc.get_InnerException();
                           strError = CLRInterop::getAnyTypeForObject( clrExcMessage );
                           throw error(strError);

3 Ocak 2014 Cuma

AXAPTA - Merge more than one purchaseses selected lines and show at PurchEditLines form

    Args                    args = new Args();
    PurchFormLetter         purchFormLetter;
    purchTable              purchTable;
    VendReceiptsListTrans   ListTrans;
    PurchParmLine           purchParmLine;
    PurchParmTable          purchParmTable;
    Object                  dialog;
    vendReceiptsListJour    Jour;
    boolean                 err;
    VendPackingSlipTrans    PackingTrans;
    select purchTable where purchTable.PurchId == this.PurchId; //select first purchtable record
    //-------------- prepare purchformletter class -----
    purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
//    purchformletter.documentNum(
    //--------------- add other purchtable records -----
    while select OrigpurchId from ListTrans
        group by ListTrans.OrigPurchId
        where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId != this.PurchId
       select purchTable where purchTable.PurchId == ListTrans.OrigPurchId;
    //---------------- delete unnecessary purchase lines --------------------
    select firstonly forupdate purchParmLine
        where purchParmLine.ParmId == purchformletter.parmId();
    if (purchParmLine.RecId == 0)
        box::stop("There isn't any purchline applicable");
//    box::warning("111");
    while select forupdate purchParmLine
        where purchParmLine.ParmId == purchformletter.parmId()
        select firstonly ListTrans where ListTrans.ReceiptsListId == this.ReceiptsListId && ListTrans.OrigPurchId == purchParmLine.OrigPurchId &&
                ListTrans.ItemId == purchParmLine.ItemId && purchParmLine.InventTransId == ListTrans.InventTransId;
       // info(strfmt("%1 %2",purchparmline.ItemId,listtrans.ItemId));
        //---eğer bu sipariş satırı giriş listesinde yoksa sil-------------
        if (ListTrans.RecId == 0)
//            info("---sil---");
       //----miktarı giriş listesinden al----------------------------------
            purchParmLine.ReceiveNow = ListTrans.PurchQty;
            purchParmLine.InventNow  = ListTrans.PurchQty;
//            purchParmLine.modifiedReceiveNow();
            purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
    update_recordset purchParmTable setting num = this.packingSlipId,
                                            TransDate = this.PackingSlipDate,
                                            DocumentDate = this.PackingSlipDate
    where purchParmTable.ParmId == purchformletter.parmId();
    if (this.packingSlipId)
        purchformletter.reArrange(true); //------------ merge purchases like push rearrange button at purcheditlines form ----
    dialog = purchformletter.dialog();
    dialog.run() ;
    if (dialog.closedOk())
            select firstonly PackingTrans join ListTrans
                where PackingTrans.purchId == ListTrans.OrigPurchId &&
                    ListTrans.ReceiptsListId == this.ReceiptsListId;
        if (PackingTrans.RecId != 0)
            update_recordset Jour setting VendReceiptsListJourStatus = DTVendReceiptsListJourStatus::PackingSlip
                where Jour.RecId == this.RecId;