Wednesday, 30 December 2015

short cut hot keys in ax 2012

say if we want a particular alphabet to be made as short cut for a functionality when we press alt :

we can achieve this by design

go to action pane button and button properties

"key tips" : select a label for a alphabet like A, B ,C and save the change now your short cut key is ready...

Tuesday, 29 December 2015

post PO by code in ax 2012


please find the code for posting PO here the code is some what lengthy it is doing some other functionality too.

public void InvoicePO(PurchTable _purchTable)
{
    PurchTable                      purchTable,purchTableCurr;
    int                             seq;
    PurchFormLetter_PackingSlip     packingSlip;
    PurchFormLetter_Invoice         invoice;

    PurchFormLetter                 confirm;
    VendInvoiceJour                 vendInvoiceJour;
    InvoiceId                       invoiceId;
    PurchLine                       purchLine;
    SalesTable                      salesTable;

    CustInvoiceJour                 custInvoiceJour;
    CustInvoiceId                   custInvoiceId;
    CustPackingSlipJour             custPackingSlipJour;
    PackingSlipId                   packingSlipId;
    VendPurchOrderJour              vendPurchOrderJour;
    DmsInterCompanySO               interCompanySO = new DmsInterCompanySO();
    DmsSOAutoPost                   dmsSOAutoPost = new DmsSOAutoPost();
    DmsCreateSalesOrder             CreateSalesOrder = new DmsCreateSalesOrder();

    purchTable  = _purchTable;//_args.record();
    seq         = this.invoiceCount(purchTable.PurchId);
    seq++;


    try
    {
        select recid from purchLine where purchLine.PurchId == purchTable.PurchId
            && purchLine.PurchReceivedNow != 0;

        if(!purchLine.RecId)
        {
            throw error("@DMS2537");
        }

        ttsBegin;
        if (VendTable::find(purchTable.OrderAccount).DmsSalesKittingEnabled && (purchTable.PurchaseType == PurchaseType::Purch || purchTable.PurchaseType == PurchaseType::ReturnItem))
        {
            DmsPopulateSupplementaryItems::createSupplementaryItemLinesPurch(purchTable);
        }
        if(PurchTable.DmsIsDropShipment)
        {
            CreateSalesOrder.run(PurchTable);
        }

        confirm = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
        confirm.update( purchTable,
                        strFmt('Conf-%1-%2',purchTable.PurchId,seq));

        if(purchTable.InterCompanySalesId && purchTable.PurchaseType == PurchaseType::Purch)
        {
            changeCompany(purchTable.InterCompanyCompanyId)
            {
                select firstonly InvoiceId from custInvoiceJour
                    where custInvoiceJour.SalesId == purchTable.InterCompanySalesId;

                custInvoiceId = custInvoiceJour.InvoiceId;

                select firstonly PackingSlipId from CustPackingSlipJour
                    where CustPackingSlipJour.SalesId == purchTable.InterCompanySalesId;

                packingSlipId = CustPackingSlipJour.PackingSlipId;
            }

            packingSlip = PurchFormLetter::construct(DocumentStatus::PackingSlip);
            packingSlip.showQueryForm(false);
            packingSlip.update( purchTable,
                                packingSlipId,
                                today(),
                                PurchUpdate::ReceiveNow,
                                AccountOrder::None,
                                false,
                                false);

            invoice = PurchFormLetter::construct(DocumentStatus::Invoice);
            invoice.showQueryForm(false);
            invoice.parmDmsReArrangeNow(false);

            invoice.update( purchTable,
                        custInvoiceId,
                        today(),
                        PurchUpdate::PackingSlip,
                        AccountOrder::None,
                        false,
                        false);
        }
        else
        {

            if( purchTable.PurchaseType == PurchaseType::ReturnItem )
            {
                // partner blocking
                //purchTable.DmsPartnerBlockingPurchaseReturnVolume();
                //purchTable.DmsPartnerBlockingPurchaseReturnValue();
                // partner blocking
                confirm = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
                confirm.update(purchTable,'',today(),PurchUpdate::All,AccountOrder::None,NoYes::No,NoYes::Yes);

                if( PurchTable.PurchaseType == PurchaseType::ReturnItem )  //07112015
                {
                    select count(RecId) from vendPurchOrderJour where vendPurchOrderJour.PurchId == PurchTable.PurchId;
                    if(vendPurchOrderJour.RecId > 0)
                    {
                        if( !PurchTable.InterCompanySalesId )
                        {
                            interCompanySO.run(PurchTable.PurchId);
                        }
                    }
                }
            }

            packingSlip= PurchFormLetter::construct(DocumentStatus::PackingSlip);
            packingSlip.showQueryForm(false);
            packingSlip.update( purchTable,
                                strFmt('PS-%1-%2',purchTable.PurchId,seq),
                                today(),
                                PurchUpdate::ReceiveNow,
                                AccountOrder::None,
                                false,
                                false);

            invoice = PurchFormLetter::construct(DocumentStatus::Invoice);
            invoice.showQueryForm(false);
            invoice.parmDmsReArrangeNow(false);

            invoice.update(purchTable,
                        strFmt('INV-%1-%2',purchTable.PurchId,seq),
                        today(),
                        PurchUpdate::PackingSlip,
                        AccountOrder::None,
                        false,
                        false);

        }


        select firstOnly purchTableCurr
            where purchTableCurr.PurchId == PurchTable.PurchId;

        if( purchTableCurr.DmsIsDropShipment && purchTableCurr.DmsDropShipmentSalesId )
        {
            salesTable = SalesTable::find(purchTableCurr.DmsDropShipmentSalesId);
            this.postSO(salesTable);
        }

        ttsCommit;

        invoiceId = strFmt('INV-%1-%2',purchTable.PurchId,seq);

        select LedgerVoucher from vendInvoiceJour where vendInvoiceJour.PurchId && vendInvoiceJour.InvoiceId == invoiceId;

        if(vendInvoiceJour.LedgerVoucher && purchTable.DmsDOReferenceNumber && !purchTable.DmsIsInterCompanyTransfer)
            info(strFmt("@DMS2536",purchTable.PurchId, purchTable.DmsDOReferenceNumber));

    }
    catch
    {
        ttsAbort;
        error("@DMS1832");
    }
}

Friday, 18 December 2015

Thursday, 17 December 2015

use cross company instead of change company more often


    changeCompany(_IMEIDelinkingTable.DataArea)
    {
        select  *
            from   DMSSerialNumTrans
                where DMSSerialNumTrans.SerialNum == _serialNum //serialNumScan.SerialNum
                &&    DMSSerialNumTrans.Company ==  curext()
                &&    DMSSerialNumTrans.IMEITransactionType == DmsSerialTransactionType::Purchase;
        select *
            from VendInvoiceTrans
                where VendInvoiceTrans.InventTransId ==  DMSSerialNumTrans.InventTransId;

        dms_IMEIDelinkingLine.PurchId = VendInvoiceTrans.OrigPurchId;
    }
    */

    select crossCompany InventTransId
            from   DMSSerialNumTrans
                where DMSSerialNumTrans.SerialNum == _serialNum//serialNumScan.SerialNum
                &&    DMSSerialNumTrans.Company ==  _IMEIDelinkingTable.DataArea//curext()
                &&    DMSSerialNumTrans.IMEITransactionType == DmsSerialTransactionType::Purchase
        join  OrigPurchId
            from VendInvoiceTrans
                where VendInvoiceTrans.InventTransId ==  DMSSerialNumTrans.InventTransId
                   && VendInvoiceTrans.dataAreaId == _IMEIDelinkingTable.DataArea;
        /*select OrigPurchId
            from VendInvoiceTrans
                where VendInvoiceTrans.InventTransId ==  DMSSerialNumTrans.InventTransId;*/

        dms_IMEIDelinkingLine.PurchId = VendInvoiceTrans.OrigPurchId;


it is better to use cross company than using change company

Monday, 14 December 2015

how to use table buffer efficently

if(!suppItemGroup)
                        {
                            suppItemGroup.clear();
                            suppItemGroup.GroupId = inventTableModule.SuppItemGroupId;
                            suppItemGroup.Module =  ModuleInventCustVend::Invent;
                            suppItemGroup.insert();                          
                        }                      
                    select ItemId,ModuleType,SuppItemGroupId
                        from inventTableModuleloc
                            where inventTableModuleloc.ItemId         == inventTableModule.ItemId
                                &&    inventTableModuleloc.ModuleType == ModuleInventPurchSales::Sales;                      
                                inventTableModuleloc.clear();
                                inventTableModuleloc.SuppItemGroupId = inventTableModule.SuppItemGroupId;                              
                                inventTableModuleloc.ModuleType      = ModuleInventPurchSales::Sales;
                                inventTableModuleloc.insert();
                                                   
                    select ItemId,ModuleType,SuppItemGroupId
                        from inventTableModuleloc
                            where inventTableModuleloc.ItemId == inventTableModule.ItemId
                                &&    inventTableModuleloc.ModuleType == ModuleInventPurchSales::Purch;                              
                                inventTableModuleloc.clear();
                                inventTableModuleloc.SuppItemGroupId = inventTableModule.SuppItemGroupId;
                                inventTableModuleloc.ModuleType      = ModuleInventPurchSales::Purch;
                                inventTableModuleloc.insert();  


if we see the above code we are using a single table buffer which we are clearing and re inserting it is better than creating a new buffer and using it.


display methods

normally we do caching of display method for the performance issue

best thing we can do is 

we can simple write on every display method top 

as 

[SysClientCacheDataMethodAttribute(true)]

that's it rest of things will be taken care..

no need to add cache method in form data source and normally try to write the display emthods on the tables rather than writing on the form level.

Thursday, 10 December 2015

code to get the child node in product hierchery

static void queryForHierarchyNodes(Args _args)
{
    EcoResCategory          ecoResCategoryMobile, ecoResCategoryInfo, ecoResCategoryLast;
    QueryRun                qRun;
    QueryBuildDataSource    qDS;
    #EcoResCategoryDefaults

    select * from ecoResCategoryMobile where ecoResCategoryMobile.RecId == 5637170077 ;//5637163389;//5637163386; //5637163389;

    qRun        = new QueryRun(new Query());
    qDS = qRun.query().addDataSource(tableNum(ecoResCategory));

    qDS.addRange(fieldNum(EcoResCategory, CategoryHierarchy))
                    .value(queryValue(ecoResCategoryMobile.CategoryHierarchy));

    qDS.addRange(fieldNum(EcoResCategory, NestedSetLeft))
                    .value(Global::queryRange(ecoResCategoryMobile.NestedSetLeft, ecoResCategoryMobile.NestedSetRight));

    qDS.addRange(fieldNum(EcoResCategory, NestedSetRight))
                    .value(Global::queryRange(ecoResCategoryMobile.NestedSetLeft, ecoResCategoryMobile.NestedSetRight));

    while (qRun.next())
    {
        ecoResCategoryInfo  = qRun.get(tableNum(EcoResCategory));
        //select ecoResCategoryLast where ecoResCategoryLast.ParentCategory == ecoResCategoryInfo.RecId;
        //if(!ecoResCategoryLast)
        {
            //info(ecoResCategoryInfo.getLeafNodes().Name);
            info(ecoResCategoryInfo.Name);
        }
    }
}

Wednesday, 9 December 2015

how to form a query based on relation

static void newjob(Args _args)
{
    EcoResDistinctProductVariant        EcoResDistinctProductVariant;
    EcoResProductVariantConfiguration   EcoResProductVariantConfiguration;
    EcoResProductMaster                 resproductmaster;
    EcoResConfiguration                 EcoResConfiguration;
    Query                   query = new Query();
    QueryRun                qr;
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildDataSource    queryBuildDataSource2;
    QueryBuildDataSource    queryBuildDataSource3;
    QueryBuildDataSource    queryBuildDataSource4;
    QueryBuildRange         queryBuildRange;
    QueryBuildRange         queryBuildRange2;
    SysTableLookup          sysTableLookup;
    EcoResConfiguration     EcoResConfiguration1;
 
   
    select * from resproductmaster  where resproductmaster.DisplayProductNumber == "SamsungS20";  
   
    while select * from EcoResDistinctProductVariant  where EcoResDistinctProductVariant.ProductMaster == resproductmaster.RecId
    {      
        select * from EcoResProductVariantConfiguration  where EcoResProductVariantConfiguration.DistinctProductVariant == EcoResDistinctProductVariant.RecId;
        select * from EcoResConfiguration  where EcoResConfiguration.RecId == EcoResProductVariantConfiguration.Configuration;
        info(strFmt("%1",EcoResConfiguration.Name));
    }
   
   
    queryBuildDataSource    = query.addDataSource(tableNum(EcoResConfiguration));
    queryBuildDataSource2   = queryBuildDataSource.addDataSource(tableNum(EcoResProductVariantConfiguration));
    queryBuildDataSource2.addLink(fieldNum(EcoResConfiguration, RecId), fieldNum(EcoResProductVariantConfiguration, Configuration));
    queryBuildDataSource3   = queryBuildDataSource2.addDataSource(tableNum(EcoResDistinctProductVariant));
    queryBuildDataSource3.addLink(fieldNum(EcoResProductVariantConfiguration, DistinctProductVariant), fieldNum(EcoResDistinctProductVariant, RecId));
    queryBuildDataSource4   = queryBuildDataSource3.addDataSource(tableNum(EcoResProductMaster));
    queryBuildDataSource4.addLink(fieldNum(EcoResDistinctProductVariant, ProductMaster), fieldNum(EcoResProductMaster, RecId));
    queryBuildDataSource4.addRange(fieldNum(EcoResProductMaster, DisplayProductNumber)).value("Galaxy S Duos Gold");

    qr = new QueryRun(query);
    while(qr.next())
    {
        EcoResConfiguration1 = qr.getNo(1);
        info(EcoResConfiguration1.Name);
    }
   
}

a query with multiple datasource

public void lookup(FormControl _formControl, str _filterStr)
{
    Query                       query = new Query();
    QueryBuildDataSource        qbds;
    QueryBuildDataSource        qbdsJoin;
    SysTableLookup              sysTableLookup;
    CompanyInfo                 CompanyInfo;
   // super(_formControl, _filterStr);
    changeCompany(DMS_IMEIDelinkingTable.DataArea)
    {
        select firstOnly DMSDivisionCode
            from CompanyInfo
                where CompanyInfo.DataArea == DMS_IMEIDelinkingTable.DataArea;
        sysTableLookup = SysTableLookup::newParameters(tableNum(InventTable), _formControl);

        qbds = query.addDataSource(tableNum(InventTable));
        qbdsJoin = qbds.addDataSource(tableNum(DmsSkuDetailsTable));
        qbds.relations(false);
        qbds.fields().dynamic(NoYes::Yes);
        qbdsJoin.addLink( fieldNum(InventTable, ItemId),fieldNum(DmsSkuDetailsTable, ProductCode));
        qbdsJoin.joinMode(JoinMode::InnerJoin);
        qbdsJoin.addRange(fieldNum(DmsSkuDetailsTable,DivisionCode)).value(CompanyInfo.DMSDivisionCode);
        qbdsJoin.addOrderByField(fieldnum(DmsSkuDetailsTable, ProductCode));
        sysTableLookup.addLookupField(fieldnum(InventTable, ItemId));
        sysTableLookup.addLookupField(fieldnum(InventTable, NameAlias));
        qbds.orderMode(OrderMode::GroupBy);
        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }
}

Monday, 7 December 2015

BP error : dateflag should be specified when calling date2str

code  :

  return date2str(_cv.date(),123,2,1,2,1,4);

it wil give bp error :

"date flags should be specified when calling date2str"

Change it too below :

return date2str(_cv.date(),123,2,1,2,1,4,DateFlags::None);





Thursday, 3 December 2015

enable or disable field based on condition ax 2012

there are 2 ways to enable or disable the fields :

1.

inventTable_ds.object(fieldnum(InventTable,ItemId)).enable(True);

2. itemid.enable(true)

always prefer first one as this is considered as best practises
and you don't need set the auto declaration == yes also.


Wednesday, 2 December 2015

Exception -The ' ' character, hexadecimal value 0x20, cannot be included in a name

private void XMLChilddata(DmsTableFieldMapping _mapping,common _recordChild)
{
    str                     strValue;
    XmlAttribute            labelAttribute;
    //InventJournalTable      InventJournalTableloc;
    InventJournalTrans      InventJournalTrans;
    //SysDictField            dict;

    if(_recordChild.TableId == InventJournalTable.TableId)
    {
        while select ItemID
            from InventJournalTrans
                where InventJournalTrans.JournalId == InventJournalTable.JournalId
        {

            childNode = doc.createElement(fieldId2name(tableName2Id("InventJournalTrans"),6));//InventJournalTrans,ItemId));
            labelAttribute = doc.createAttribute("Item  ID");//error here because there is blankspace 
            labelAttribute.value(InventJournalTrans.ItemId);
            childNode.attributes().setNamedItem(labelAttribute);
            strValue  = strFmt("%1",(_recordChild.(fieldnum(InventJournalTrans,ItemID))));
            childNode.innerText(strValue);
            parentNode.appendChild(childNode);
        }
    }

so it should be

private void XMLChilddata(DmsTableFieldMapping _mapping,common _recordChild)
{
    str                     strValue;
    XmlAttribute            labelAttribute;
    //InventJournalTable      InventJournalTableloc;
    InventJournalTrans      InventJournalTrans;
    //SysDictField            dict;

    if(_recordChild.TableId == InventJournalTable.TableId)
    {
        while select ItemID
            from InventJournalTrans
                where InventJournalTrans.JournalId == InventJournalTable.JournalId
        {

            childNode = doc.createElement(fieldId2name(tableName2Id("InventJournalTrans"),6));//InventJournalTrans,ItemId));
            labelAttribute = doc.createAttribute("Item ID");//so no error now
            labelAttribute.value(InventJournalTrans.ItemId);
            childNode.attributes().setNamedItem(labelAttribute);
            strValue  = strFmt("%1",(_recordChild.(fieldnum(InventJournalTrans,ItemID))));
            childNode.innerText(strValue);
            parentNode.appendChild(childNode);
        }
    }

Tuesday, 24 November 2015

cross company and change company

DataAreaId                  localDataArea = curext();

    InventItemOrderSetupType    setupType   = InventItemOrderSetupType::Invent;
    InventJournalCheckPost      journalCheckPost = new InventJournalCheckPost();

    //change company
    changeCompany(_DMS_IMEIDelinkingTable.DataArea)
    {

        ttsbegin;
        this.progressbar();
        inventJournalTable.clear();
        num = new NumberSeq();
        num = NumberSeq::newGetNum(InventParameters::numRefTransferId());

        inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().LossProfitJournalNameId));
        inventJournalTable.DMSRequestID = _DMS_IMEIDelinkingTable.DMSRequestID;
        inventJournalTable.Description  = "";
        inventJournalTable.insert();

        while select crossCompany DMSCurrentItermID, IMEI, DMSNewItemID from  IMEIDelinkingLine
            where IMEIDelinkingLine.DMSRequestID == _DMS_IMEIDelinkingTable.DMSRequestID
                && IMEIDelinkingLine.dataAreaId  == localDataArea
        {
            inventJournalTrans.clear();
//do the business logic
        }


change company : it changes the from current company to the current company.

cross company : normally when we select the table it will display the data related to company  id .

when  can select the cross company it select all the company records from the table and we can use it for flteration.

cross company in query

 this.query().allowCrossCompany(true);

        this.query().dataSourceTable(tablenum(InventJournalTable)).addRange(fieldNum(InventJournalTable,RequestID)).value(parmId);

        query = this.query();

Sunday, 11 October 2015

data migration process from one db to other DB

Data Migration Process
                                                Data migration is the process of migrating data from one database to another database (i.e importing data from source db to target db) by mapping the fields of source and destination tables respectively.
Here we followed the process using SQL server integration tool (i.e DB to DB importing process )
à Open Visualstudio select new project Templates > Business Intelligence >Integrated services
àIn integrated services >select the Solution Explorer >Go to SSIS Packages >new Package >rename the package
àOn the left hand side select the dataflow >drag & drop the OLE DB source component and OLE DB destination component.
àNow goto OLE DB Source> double click on it > Select the server name, database name & table name (i.e from this server, database & table, the data is ready to import on destination) then click ok
Note: while clicking ok please check the columns are marked or not
Example: Here we selected servername as INSVR07, DB as TTC_2009, Sales Table, check test connection whether the connection is succeeded or not
àSelect the Source component, map it to the destination component (i.e select source component then one blue down arrow appears on it just simply drag it on the destination component)
àNow Double Click on the destination > Select the server name, database name & table name (i.e to this server, database, table the data is going to import from the source) now click on mapping and Map the both fields and click ok
Example: Here we selected servername as INSVR07, DB as TTC_2012, Sales Table, check test connection whether the connection is succeeded or not
àif any error symbols shows it means mapping doesn’t done correctly or if no any errors occurs mapping was done successfully
àFinally, Select both source and destination components then right click > Select execute Task
  If it shows any error occurs check it in process tab.

àNow the data is imported from source to destination tables

Monday, 21 September 2015

code for making bold letters for a dialogue text in ax 2012

Dialog dialog = new Dialog();
DialogText dt = dialog.addText("Test");
FormBuildStaticTextControl txtCtl = dt.control();
txtCtl.bold(7);

dialog.run();

Saturday, 19 September 2015

Code is working fine in Dev VM but in Test VM it is not working fine

Say we have developed one functionality or some customization in some so called form in dev VM and you have moved the code to test VM and you observe that  the code is not working fine as it is supposed to be.

Please go to test VM and clear the cache and refresh the table, data dictionary,

after that the code should work fine as it is supposed to be.

Tuesday, 15 September 2015

bp error - The relation under the extended data type (EDT) SalesIdBase must be migrated to a table relation. Consider using the EDT relation migration tool.

  some time we get bp error when we set the compiler level to 4 and go the compilation of code

like :

The relation under the extended data type (EDT) SalesIdBase must be migrated to a table relation. Consider using the EDT relation migration tool.


go to development AX then click on tools>>>code upgrade>> edt migration tool select the table in right hand side you will have migrate all   then in top  click on migrate single table and at last you will get message like edt has been migrated for the table.

Wednesday, 9 September 2015

Moving projects across models in ax 2012

 Moving projects across models

When moving a project from one model to another there is a particular process that must be followed:
1)    Create a new dummy project in any model

2)    Move all items from the current project into the dummy project
3)    Move the original project (now empty), into the new model
4)    Move all the items back from the dummy project into the original project
The reason for this set of rules exists due to the fact that if a project with elements in mixed models is moved to a new model, it will update all the child object to the same model.




can we  create a new project  in a new model and  move the  objects  from the  projects to newly created project.

Tuesday, 8 September 2015

look up with the all table fields of a table in ax 2012

Please refer :

 \Classes\WrkCtrBulkEditController\init          

protected void init()
{
    FormRun             callerForm;
    FormDataSource      callerFormDataSource;
    FormDataSource      baseFormDataSource;
    DictTable           dictTable;
    fieldId             currentFieldId;
    WrkCtrBulkEditField wrkCtrBulkEditField;
    int                 dataSourceCount;
    int                 dataSourceIndex;
    int                 fieldMapKey = 0;

    if( formObject && formObject.args() )
    {
        callerForm = formObject.args().caller();
    }

    if( callerForm )
    {
        baseFormDataSource = callerForm.dataSource();

        dataSourceCount = callerForm.dataSourceCount();

        for (dataSourceIndex = 1; dataSourceIndex <= dataSourceCount; ++dataSourceIndex)
        {
            callerFormDataSource = callerForm.dataSource(dataSourceIndex);

            if (!this.isInnerJoined(baseFormDataSource, callerFormDataSource))
            {
                continue; // only process inner-joined datasources
            }

            dictTable = new DictTable( callerFormDataSource.table() );

            if (dictTable && hasTableAccess(dictTable.id()))
            {

                for( currentFieldId = dictTable.fieldNext(0); currentFieldId; currentFieldId = dictTable.fieldNext(currentFieldId) )
                {
                    wrkCtrBulkEditField = WrkCtrBulkEditField::newFromDatasourceField(callerFormDataSource, dictTable.fieldObject(currentFieldId) );

                    //if( wrkCtrBulkEditField.isEditable() )
                    {
                        fieldsMap.insert( fieldMapKey, wrkCtrBulkEditField );
                        fieldMapKey++;
                    }

                }
            }
        }
    }
}

Please debug this class and find out how the look up is getting created                                                52

Sunday, 30 August 2015

classes for changing the amount for the vouchers of sales order invoice

markup class and method :calcTrans

under that

this class is usally called when ever we create a sales order  and check the auto charges linked with the sales order based on the selection on the auto charges form set up.

Sunday, 16 August 2015

look up on table and calling it on form datasource

create a method on table like

public client static void lookupInvoiceDayOKN(FormStringControl _ctrl, PaymDayId _filter)
{
 
    // Intantiantes a SysTableLookup object telling it which control activated the lookup, and
    // what table should be displayed inside the lookup form.
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(PaymDay), _ctrl);

    Query query = new Query(); // This query will be used by the lookup form.
    QueryBuildDataSource qbds;

    ;

    // The "addLookupField" method adds the the fields that will be shown inside the lookup's grid.
    // The second, boolean parameter indicates that this field will be returned from the lookup when a
    // record is selected. In this case, we'll return our DummyPK.
    sysTableLookup.addLookupField(fieldnum(PaymDay, PaymDayId), true);
    //sysTableLookup.addLookupField(fieldnum(PaymDay, Field1));
    //sysTableLookup.addLookupField(fieldnum(PaymDay, Field2));
    //sysTableLookup.addLookupField(fieldnum(PaymDay, Field3));


    // Using our dummy table as a DataSource Table.
    qbds = query.addDataSource(tablenum(PaymDay));

    // This is the key part, what we want to filter to be displayed in the grid.
   // qbds.addRange(fieldnum(PaymDay, PaymDayId )).value(_filter);


    // Passes the query to the sysTableLookup.
    sysTableLookup.parmQuery(query);

    // Activates the lookup.
    sysTableLookup.performFormLookup();
}

then go the form data source of the field and then

over ride the look up method of the same and JUST CALL THE STATIC METHOD OF THAT TABLE LIKE

public void lookup(FormControl _formControl, str _filterStr)
{
    super(_formControl, _filterStr);
    SellingModelOKN::lookupInvoiceDayOKN(_formControl, "invoice day");
}


here we go our look up is ready......

but always try to create a look up by relation as it is more flexible...

Wednesday, 12 August 2015

how to use visual studio profiler

steps to use Visual Studio Profiler:

Note Visual Studio Profiler is available with Visual Studio 2010 Premium and Visual Studio
2010 Ultimate editions.

In Visual Studio, on the Debug menu, click Options And Settings.
2. In the left pane of the Options dialog box, click Debugging, and then click Symbols, and
ensure that the symbol file is loaded for the XppIL folder of the AOS that you want to profile.
(The profiling tools use symbol [.pdb] files to resolve symbolic names such as function names
in program binaries.)
3. On the Analyze menu, click Launch Performance Wizard to create a new performance session.
4. Accept the default setting of CPU Sampling, and point to the AOS that you want to profile, but
don’t start profiling right away.
5. Open Performance Explorer, right-click the top node of your session , and then
click Properties.



6. In the Properties window, navigate to Sampling and decrease the sampling interval either to
100,000 or 1,000,000 to get better results.
7. Prepare the process that you want to profile, and then click Attach/Detach to attach
to the
process (for example, the AOS).
8. When you are done profiling, click Attach/Detach to detach from the AOS.

After you finish profiling, Visual Studio generates a report that helps you understand the
performance
problem in detail, as shown in figure


strating a trace from x++ code

Start a trace through code instrumentation
You can use the xClassTrace class from the Tracing Cockpit to start and stop a trace. To trace the Sales
Form letter logic, see the following sample in \Classes\SalesFormLetter:
// Add
xClassTrace xCt = new xClassTrace();
// to the variable declaration.
// …code…
if (salesFormLetter.prompt())
{
xClassTrace::start("c:\\temp\\test1.etl");
xClassTrace::logMessage("test1");
xCt.beginMarker("marker"); // Add markers at certain points of a trace to
// increase trace readability. You can add
// multiple markers per trace.
salesFormLetter.run();
xCt.endMarker("marker");
xClassTrace::stop();
outputContract = salesFormLetter.getOutputContract();
numberOfRecords = outputContract.parmNumberOfOrdersPosted();
}
// …code…
In the call to xClassTrace::start, you can use multiple parameters to specify the events to trace or
whether you want to use circular logging, among other things. To find out which keyword equals
which parameter, put a breakpoint in the class SysTraceCockpitcontroller\startTracing and start a trace
from the Tracing Cockpit with various events selected

Monday, 10 August 2015

Cannot select a record in Order lines (SalesLine). The SQL database has issued an error. SQL error description: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'XYZ'.

when we get error like this :

Cannot select a record in Order lines (SalesLine).
The SQL database has issued an error.
SQL error description: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'XYZ'.
T1.SALESID,T1.LINENUM,T1.ITEMID,T1.SALESSTATUS,T1.NAME,T1.EXTERNALITEMID,T1.TAXGROUP,T1.QTYORDERED,T1.SALESDELIVERNOW,T1.REMAINSALESPHYSICAL,T1.REMAINSALESFINANCIAL,T1.COSTPRICE,T1.SALESPRICE,T1.CURRENCYCODE,T1.LINEPERCENT,T1.LINEDISC,T1.LINEAMOUNT,T1.CONFIRMEDDLV,T1.RESERVATION,T1.SALESGROUP,T1.SALESUNIT,T1.PRICEUNIT,T1.PROJTRANSID,T1.INVENTTRANSID,T1.CUSTGROUP,T1.CUSTACCOUNT,T1.SALESQTY,T1.SALESMARKUP,T1.INVENTDELIVERNOW,T1.MULTILNDISC,T1.MULTILNPERCENT,T1.SALESTYPE,T1.BLOCKED,T1.COMPLETE,T1.REMAININVENTPHYSICAL,T1.TRANSACTIONCODE,T1.TAXITEMGROUP,T1.TAXAUTOGENERATED,T1.UNDERDELIVERYPCT,T1.OVERDELIVERYPCT,T1.BARCODE,T1.BARCODETYPE,T1.INVENTREFTRANSID,T1.INVENTREFTYPE,T1.INVENTREFID,T1.INTERCOMPANYORIGIN,T1.ITEMBOMID,T1.ITEMROUTEID,T1.LINEHEADER,T1.SCRAP,T1.DLVMODE,T1.INVENTTRANSIDRETURN,T1.PROJCATEGORYID,T1.PROJID,T1.INVENTDIMID,T1.TRANSPORT,T1.STATPROCID,T1.PORT,T1.PROJLINEPROPERTYID,T1.RECEIPTDATEREQUESTED,T1.CUSTOMERLINENUM,T1.PACKINGUNITQTY,T1.PACKINGUNIT,T1.INTERCOMPANYINVENTTRANSID,T1.REMAININVENTFINANCIAL,T1.DELIVERYNAME,T1.DELIVERYTYPE,T1.CUSTOMERREF,T1.PURCHORDERFORMNUM,T1.RECEIPTDATECONFIRMED,T1.STATTRIANGULARDEAL,T1.SHIPPINGDATEREQUESTED,T1.SHIPPINGDATECONFIRMED,T1.ADDRESSREFRECID,T1.ADDRESSREFTABLEID,T1.SERVICEORDERID,T1.LINEDELIVERYTYPE,T1.SHIPCARRIERID,T1.SHIPCARRIERACCOUNT,T1.SHIPCARRIERDLVTYPE,T1.SHIPCARRIERACCOUNTCODE,T1.SALESCATEGORY,T1.DELIVERYDATECONTROLTYPE,T1.ACTIVITYNUMBER,T1.LEDGERDIMENSION,T1.RETURNALLOWRESERVATION,T1.MATCHINGAGREEMENTLINE,T1.SYSTEMENTRYSOURCE,T1.SYSTEMENTRYCHANGEPOLICY,T1.MANUALENTRYCHANGEPOLICY,T1.ITEMREPLACED,T1.RETURNDEADLINE,T1.EXPECTEDRETQTY,T1.RETURNSTATUS,T1.RETURNARRIVALDATE,T1.RETURNCLOSEDDATE,T1.RETURNDISPOSITIONCODEID,T1.DELIVERYPOSTALADDRESS,T1.SHIPCARRIERPOSTALADDRESS,T1.SHIPCARRIERNAME,T1.DEFAULTDIMENSION,T1.SOURCEDOCUMENTLINE,T1.STOCKEDPRODUCT,T1.ITEMPBAID,T1.PSAPROJPROPOSALQTY,T1.PSAPROJPROPOSALINVENTQTY,T1.PDSEXCLUDEFROMREBATE,T1.RETAILVARIANTID,T1.LRTISSUETYPE,T1.LRTTRANSACTIONTYPE,T1.LRTINVENTTRANSIDTO,T1.LRTINVENTDIMIDTO,T1.LRTRENTALFROMDATETIME,T1.LRTRENTALFROMDATETIMETZID,T1.LRTRENTALTODATETIME,T1.LRTRENTALTODATETIMETZID,T1.LRTBUNDLEID,T1.LRTOPERATINGUNITVALUE,T1.LRTOPERATINGUNITUNITID,T1.LRTPERCENTOFBASEPRICE,T1.LRTTIMEUNITQTY,T1.LRTTIMEUNITPRICE,T1.LRTOPERATINGUNITPRICE,T1.LRTTARIFFUNITID,T1.LRTPRICEACQUISITIONCODE,T1.LRTRENTALWORKTIMEID,T1.LRTPRICESCALETYPE,T1.LRTPRICESCALE,T1.LRTPRICINGITEMID,T1.LRTOPERATINGUNITEXCEPTEDQTY,T1.LRTPRICESCALEID,T1.LRTPROJECTLEVEL1,T1.LRTPROJECTLEVEL2,T1.LRTPROJECTLEVEL3,T1.LRTPROJECTLEVEL4,T1.LRTCOMPANYSRCCOUNTRY,T1.LRTISCONSTRUCTION,T1.LTMPUSHQTY,T1.LTMPULLQTY,T1.LRTTAXGROUPRENTAL,T1.LRTISRENTALINVOICE,T1.LRTRENTEDITEMID,T1.LRTRENTALISSUEREFID,T1.LRTRENTALRECEIPTREFID,T1.LRTRENTALISSUETYPE,T1.LRTRENTALRECEIPTTYPE,T1.LTMSHIPMENTFRAMEWORKID,T1.LRTSALESQUOTATIONINVENTTRANSID,T1.LRTSALESORDERSTATUSID,T1.LRTACCRUEDRENT,T1.LRTRENTALSTOCKTRANSIDSALES,T1.LWSISWARRANTYCASE,T1.LTMREQUESTEDDELIVERYUNTIL,T1.LTMREQUESTEDDELIVERYUNTILTZID,T1.LTMREQUESTEDDELIVERYFROM,T1.LTMREQUESTEDDELIVERYFROMTZID,T1.LRTISLWSORDERTABLE,T1.LRTISPREPAYMENT,T1.LRTLINEDISCRENTALOPERATINGUNIT,T1.LRTLINEDISCRENTALTIMEUNIT,T1.LRTLINEPERCRENTALOPERATINGUNIT,T1.LRTLINEPERCRENTALTIMEUNIT,T1.LRTREPLACEMENTITEMID,T1.LRTREPLACEMENTINVENTSERIALID,T1.LRTINSURANCEREFINVENTTRANSID,T1.LRTISTIMERECORDPOSITION,T1.LRTESTABLISHEDSTAFFACTIVITYID,T1.LRTINCLUDEDINALLINCLUSIVE,T1.LRTORIGINVENTTRANSID,T1.LRTINVENTTRANSIDRETURN,T1.LRTREFUNDINGLINE,T1.LRTPERMISSIONVALIDFROM,T1.LRTPERMISSIONVALIDFROMTZID,T1.LRTPERMISSIONVALIDTO,T1.LRTPERMISSIONVALIDTOTZID,T1.LRTRENTEDINVENTDIMID,T1.LRTPROCESSREASONID,T1.LRTTRAFFICMEASURESSTATUS,T1.LRTTRAFFICMEASURES,T1.LRTESCORTSTATUS,T1.LRTESCORT,T1.LRTAPPROVALSTATUS,T1.LRTAPPROVAL,T1.LRTSETTINGUPPERSONNELREQUIRED,T1.LRTPROCESSINGSTATUS,T1.LRTRESPONSIBLEINVENTSITEID,T1.LRTRESPONSIBLEDEPARTMENTID,T1.LRTFREEOFCHARGE,T1.LRTLINENUM,T1.LRTLINEGROUPINGTYPE,T1.LRTRENTALPRICECHANGETYPE,T1.LRTRENTALSTOCKTRANSCONDITIONS,T1.LRTRENTALSTOCKIDREFRENTALSWAP,T1.LRTGROUPHEADERPRICECALCULATED,T1.LRTPRICEORIG,T1.LRTTIMEUNITPRICEORIG,T1.LRTORIGCALCGROUPTABLEID,T1.LRTCALCGROUPID,T1.LRTLINENUMSORTABLE,T1.LRTTRANSPORTDIRECTIONTYPE,T1.LRTPARENTINVENTTRANSREFID,T1.LRTISSERVICE,T1.LRTSERVICEREFINVENTTRANSID,T1.LRTCALCULATESALESFEECOLLECTION,T1.LRTSERVICEOBJECT,T1.LRTSERVICETYPE,T1.LRTVALIDITYPERIOD,T1.LRTCOVERAGEPERCENT,T1.LRTCALCULATIONPRICE,T1.LRTCALCVALID,T1.LRTBLOCKEDFORINVOICING,T1.LRTCLOSURERENTALTERMREFRECID,T1.LRTISSITE2SITETRANSFER,T1.LRTPRINTSUBITEM,T1.LRTPRINTPRICE,T1.AGREEMENTSKIPAUTOLINK,T1.DLVTERM,T1.MCRORDERLINE2PRICEHISTORYREF,T1.PDSBATCHATTRIBAUTORES,T1.PDSITEMREBATEGROUPID,T1.PDSSAMELOT,T1.PDSSAMELOTOVERRIDE,T1.PSACONTRACTLINENUM,T1.RETAILBLOCKQTY,T1.LTMISORDER,T1.SELLINGMODELIDOKN,T1.PAYMMODEOKN,T1.PAYMSCHEDIDOKN,T1.PAYMTERMIDOKN,T1.CSIPDMALTERNATEEXTENDED,T1.CSIPDMALTERNATESPLITMETHOD,T1.CSIPDMITEMIDORIG,T1.CSIPDMLCPEFFECTIVITYDATESOVERRIDE,T1.CSIPDMREVISIONRULEOVERRIDE,T1.CSIPDMREVISIONUSEUPSPLITMETHOD,T1.DIRECTDEBITOKN,T1.MONTHSOKN,T1.MONTHLYFEEOKN,T1.GAMECONVERSIONTERMOKN,T1.NUMBEROFWARRANTYCONVERSIONSOKN,T1.PCPRICEMODELOKN,T1.AVERAGERENTALFEEPERDAYSYC,T1.CUSTOMERNOTIFICATIONDATEOKN,T1.DIRECTDEBITAUTHORITYRECEIVEDOKN,T1.DIRECTDEBITAUTHORITYRECEIVEDOKNTZID,T1.ESTIMATEDINSTALLATIONDATEOKN,T1.FULLYEARUPFRONTLICENSEBILLINGOKN,T1.GAMECATEGORYOKN,T1.GAMEPROGRAMNUMBEROKN,T1.GAMETHEMEOKN,T1.LICENSEBILLINGSOREQUIREDOKN,T1.ORDERLINESTOPPEDOKN,T1.REGULATORNOTIFICATIONDATEOKN,T1.REGULATORYNOTIFIEDDATEOKN,T1.REVENUEMONTHOKN,T1.RRTERMIDSYC,T1.CURRENTMONTHSOKN,T1.NONCURRENTMONTHSOKN,T1.TOTALMONTHSBILLEDOKN,T1.TOTALMONTHREMAINGOKN,T1.ACTUALINSTALLDATEOKN,T1.MODIFIEDDATETIME,T1.MODIFIEDBY,T1.CREATEDDATETIME,T1.CREATEDBY,T1.RECVERSION,T1.PARTITION,T1.RECID,T1.LRTNOTICE,T1.LRTPROCESSREASONCOMMENT FROM SALESLINE T1 WHERE (((PARTITION=?) AND (DATAAREAID=?)) AND ((SALESID=?) AND (((SALESSTATUS<>?) AND (SALESSTATUS<>?)) OR (SALESDELIVERNOW<>?))))

solution:
go to the SQL database 
select * from SALESLINE
select * into SALESLINE_TMP from SALESLINE
drop table SALESLINE

run above 3 instructions and then synchroize the table from ax.
later restore the table tmp to sales line main.


if the above  steps dont help then 

follow the instructions 
in this link :
http://alexondax.blogspot.com.au/2014/08/ax-2012-tfs-solving-update-conflicted.html


find the realtion vetween 2 tables by x++ code

Please find the link for finding relation between 2 tables by code.

https://lalitoberoi.wordpress.com/2014/08/29/how-to-find-relation-between-two-tables-from-x-code/

Tuesday, 21 July 2015

how to pass multiple query value from an container or table to query run.

1.create a method in a class

str fieldListRange(FieldName _fieldName, str _value)
{

    container c;
    int countNumber;
    str rangeValue;
    A_InventImport   A_InventImport   ;
    ;

    while select * from  A_InventImport  
    {
     // c = conins(c,A_InventImport   .itemid);
     c+= A_InventImport   .ItemId;
    }

   for (countNumber = 1; countNumber <= conLen(c); countNumber++)

    {

    if(rangeValue)

    {

    rangeValue +="||";
    }

    rangeValue +="(" + _fieldName + " = \"" + strLRTrim(any2str(conPeek(c, countNumber))) + "\")";
    }
    return rangeValue;
}



then call this method in run method

queryRun.query().dataSourceTable(tablenum(inventsum)).addRange(fieldnum(inventsum,Closed)).value(queryvalue(noyes::Yes));
        queryRun.query().dataSourceTable(tablenum(inventsum)).addRange(fieldnum(inventsum,itemid)).value((strFmt("(%1) || (%2 = %3)",
        this.fieldListRange(fieldStr(A_InventImport   , ItemId), parameter1),
        fieldStr(A_InventImport   , ItemId), SysQuery::valueEmptyString())));

declare parameter1  as a string in the run method.

Wednesday, 8 July 2015

add the item image to RDP report in ax 2012

   
//line below is the link  SalesQuotationTable  && custQuotationJour
 SalesQuotationTable                = custQuotationJour.salesQuotationTable();
        salesQuotationTmp.TCC_totalDiscount      = SalesQuotationTableloc.TCC_TotalDiscount;

        //if image is there
        if(SalesQuotationTable.PrintImage == NoYes::Yes)  //customized field
        {
        ProductImage = Inventtable::find(salesQuotationTmp.ItemId).RecId;
        ProductImage1 = docuRef::find(custQuotationTrans.dataAreaId,ProductImage).RecId;
        select ecoResProductImage
        where (ecoResProductImage.RefRecId              == ProductImage
                                  || ecoResProductImage.RefRecord                == ProductImage)
                                  && ecoResProductImage.DefaultImage == NoYes::Yes ;
        salesQuotationTmp.ItemImageLogo  = ecoResProductImage.MediumSize;

        }


above code can be used to get  image stored in ecoResProductImage for the item to your temp table in the SSRS report.

Tuesday, 7 July 2015

Best 25 blogs in ax 2012

Please find the best 25 blogs in AX 2012 and they have been awarded a badge for the same.

http://www.dynamics101.com/2014/06/top-25-dynamics-ax-sites/

Friday, 3 July 2015

Cannot edit a record in Sales orders (SalesTable). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

Some time when we do deletion  or updation.

then we might get error like
"Cannot edit a record in Sales orders (SalesTable). An update conflict occurred due to another user process deleting the record or changing one or more fields in the record."

the solution for that is we need to add the

SalesTable.reread();

before  doing the SalesTable.update();

by doing this that error will not come  again.

                salesTable.reread();
                salesTable.CloseSO              = noYes::Yes;
                salesTable.update();




Thursday, 2 July 2015

cancel sales order code with updating the inventory qty for the item in ax 2012

public static void closeSalesOrders(Guid _transId)
{
    #AviFiles
    SysOperationProgress        progress  = new SysOperationProgress();
   
    SalesTable                      salesTable;
    SalesLine                       salesLine;
    ;

    progress.setCaption("Sales order closing ....");
    progress.setAnimation(#AviSearch);
    try
    {
        ttsbegin;
     
            while select firstonly forupdate salesTable
                where salesTable.SalesId            == salesOrderClosing.SalesId
            {
                while select forupdate salesline
                    where salesLine.SalesId         == salesTable.SalesId
                    && salesLine.SalesStatus        == salesStatus::Backorder
                {
                    salesLine.RemainInventPhysical  = 0;
                    salesLine.RemainSalesPhysical   = 0;
                    salesLine.Complete              = noYes::Yes;
                    salesLine.Blocked               = noYes::Yes;
                    salesLine.update();
                    progress.setText('Processing item ' + salesLine.ItemId + ' with sales id ' + salesLine.SalesId + '.');
                }
             
                    }
               

        ttscommit;

    }
    catch(Exception::Error)
    {
        ttsabort;
    }
}

Tuesday, 23 June 2015

how to add the inventory dimesnions to customized form in ax 2012

I have found a very good link for   adding the inventory dimension in the customized form



https://daxbeginners.wordpress.com/2014/08/05/how-to-dynamically-display-inventory-dimension/

creating a fact box in ax 2012

Use the following step procedure to create a simple FactBox to display the
customer's pets. A FactBox uses a Query, which is similar to a View. It is used to
select data from one or more tables.

1. In the AOT, right-click the Queries node and select New Query.
Rename the new query to VetCustPetInfoPart.
2. In a second AOT, locate the VetCustPetTable table.
3. Drag the VetCustPetTable table to the DataSources node on the
VetCustPetInfoPart query.
4. Expand the VetCustPetTable_1 data source.
5. In the property sheet for the fields node set the Dynamic property to
Yes. This means all fields in the table will be included in the query.
6. In a second AOT, locate the VetBreedTable table.
7. Drag the VetBreedTable to the DataSources node on the
VetCustPetTable_1 datasource.
8. In the property sheet for the VetBreedTable_1 datasource, set the
Relations property to Yes.
9. In the property sheet for the fields node on the VetBreedTable_1
datasource, set the Dynamic property to Yes.
10. Save your changes to the VetCustPetInfoPart query.
11. Expand the Parts node in the AOT.
12. Right-click the Info Parts node and select New Info Part.
13. In the property sheet for the new info part, set the Name property to
VetCustPetTableInfoPart, set the Caption property to Pets, set the
Query property to VetCustPetInfoPart.
14. Right-click the Layout node in the info part, and select New Group.
15. In the property sheet for the group, set the Repeating property to
Yes.
16. Right-click the new group and select New Field.
17. In the property sheet for the new field, set the DataSource property
to VetCustPetTable_1, and the DataField property to Name.
18. Right-click the group and select New Field to create a second field.
19. In the property sheet for the second field, set the DataSource.
property to VetBreedTable_1 and the DataField property to Name
20. Save your changes to the VetCustPetTableInfoPart info part.

Procedure: Adding a FactBox to a List Page
Use the following step procedure to add the FactBox to the customer's list page.
1. Create a new menu item for the info part, by dragging the
VetCustPetTableInfoPart to the Menu Items > Display node in
the AOT.
2. Locate the VetCustPetTable table in the AOT.
3. Expand VetCustPetTable table.
4. Right-click the Indexes node and select New Index
5. Rename the index to CustIdx
6. From the fields node on the table, drag the CustAccount field to the
CustIdx index.
7. Save your changes to the table.
8. Locate the CustTableListPage form in the AOT.
9. Drag the VetCustPetTableInfoPart menu item to the Parts node.
10. In the property sheet for the new part reference, set the
DataSourceRelation property to
EDT.VetCustPetTable.CustAccount.
11. Save your changes to the CustTableListPage form.
12. Open the customer's list page and notice the new info part in the
FactBox section of the form.

Thursday, 18 June 2015

how to apply filter in a list page form

List page always extends to its listpage interaction class and if you go there in the respective list page interaction class you will find a method like

public void initializeQuery(Query _query)
{
    QueryBuildDataSource    qbds;
    ProjInvoiceTable        projInvoiceTable;

    if (this.listPage().listPageArgs() &&
             this.listPage().listPageArgs().externalRecord() &&
             this.listPage().listPageArgs().menuItemName() ==  menuitemDisplayStr(ProdTableListPage_Proj) &&
             this.listPage().listPageArgs().externalRecord().TableId == tableNum(ProjInvoiceTable))
    {
        projInvoiceTable = this.listPage().listPageArgs().externalRecord();
        qbds = _query.dataSourceTable(tableNum(ProdTable)).addDataSource(tableNum(ProjTable));
        qbds.relations(true);
        qbds.joinMode(JoinMode::ExistsJoin);
        qbds.addRange(fieldNum(ProjTable,ProjInvoiceProjId)).value(queryValue(ProjInvoiceTable.ProjInvoiceProjId));
    }

    super(_query);
}

here we can add our ranges and values to apply filter on the list page form.

Wednesday, 17 June 2015

how to add multiple ranges in a query for the enum

public void init()
{
    super();
    SalesQBR = this.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable,SalesStatus));
    SalesQBR.value(strfmt("%1,%2",enum2str(SalesStatus::Canceled),enum2str(SalesStatus::Delivered)));
}

Tuesday, 9 June 2015

classes triggered while doing sale order journal posting in ax 2012

SalesInvoiceJournalPost - this is the class triggred when we invoice the sale order

MCRLedgerJournal_CustPayment - this is class for creation of journal in ax 2012 while we do sales invoice, here creation is done by the AX journal classes so only the insert method of the ledgerjournaltrans does not hit.

please note- first journal are posted and then sales order is invoiced

please note while debugging make sure that

tools>>options>>development>>execute  business logic is unchecked  so that this class will hit.

Monday, 8 June 2015

Workflow devlopment error

In this issue goona discuss something about work flow :

Say the development  of workflow is completed and still the workflow is not running and information bar is not comming to the form.

possible outcomes:

1. The cansubmit method in the table is not returning true
solution: put a debugger and open the form and check the outcome

2. the workflow is not attached properly in the form design

solution- form>>design

workflow enabled -yes
datasource- attach the table name
workflow type- attched the workflow type over there.

3. the work flow may not be created from the fron end worflow parameter

solution- create a new workflow  and give the proper workflow name like "Sales Order approval"  in the options , otherwise it will take thedefault  workflow name(XYZ_WorkflowSalesOrder) itself and will display it on the information(yellow bar).

Wednesday, 3 June 2015

How to get the previous field value in the modifiedField method of a Dynamic Ax table for form

In table we can use :

this.orig().(_fieldId)

and in form we can use like

x = Salesline.orig().lineAmount;

here x will return the last value before field was modified.

Tuesday, 2 June 2015

Simplest way to disable all the financial dimension on the CustTable form

In ax 2012 we may have many sitiuations where we need to disable one financial dimension or some or all of the dimension.

normal way we need to write some code here and there.

simplest way is to change just a condtion in the Custtable form and it will disable all the dimension.


Custtable>>init method(form)
normal code is :

 dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(true, true, true, 0, this, tabFinancialDimensions, "@SYS138487");

change it to:

 dimensionDefaultingController = DimensionDefaultingController::constructInTabWithValues(true, true, false, 0, this, tabFinancialDimensions, "@SYS138487");

now all the financial dimensions will be disabled.

Monday, 18 May 2015

New and simple way of creating Query in ax 2012

Guys if you create a query using tables every time you add a new table you need to  go to table properties and  set the table field's properties as no or yes and if you don't do then it will throw the error message.

turn around for the same is.

1. create a query(query>>new query)
2.drag the tables directly from the form datasource which has tables which u need
3.see the difference it will not throw the error message and same time it will select all the fields which are there in the tables.


Saturday, 4 April 2015

generate multiple records in AX AIF 2012 error (invalid end points)


when you run this job  sometimes  you may get a error as invalid end points



static void GenerateMutiplerecords(Args _args)
{
    CustTable           custTable;
    AxdSendContext      axdSendContext      = AxdSendContext::construct();
    AifEntityKey        aifEntityKey        = AifEntityKey::construct();
    AifConstraintList   aifConstraintList   = new AifConstraintList();
    AifConstraint       aifConstraint       = new AifConstraint();
    AifEndpointList     endpointList;
    AifActionId         actionId;
    Query               query;
    QueryBuildDataSource    qbds;

    query               = new Query(queryStr(AxdCustomer));
    AxdSend::removeChildDs(query);

    actionId            = AifSendService::getDefaultSendAction(classnum(CustCustomerService), AifSendActionType::SendByQuery);
    aifConstraint.parmType(AifConstraintType::NoConstraint);
    aifConstraintList.addConstraint(aifConstraint) ;
    endpointList        = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);

    AifSendService::SubmitFromQuery(actionId,endpointList,query,AifSendMode::Async);
}



solution for this is  when you create a outbound port  and  you select  your service which in this case is   and then you need to select all the  action ID you created   for the particular
service.(CRUDFFK)
then activate the service from the outbound port and  run this job

then run this job

static void ADCOutboundProcessing(Args _args)
{
new AifOutboundProcessingService().run();
new AifGatewaySendService().run();
info("Done");
}



then you will see an XML created in the respective  folder which was selected  for the path in AX 2012   and when you open the path you will get the multiple records over there

Sunday, 22 March 2015

pass value from form to class in AX 2012

here we want to pass the value from the form to class.



if (args.caller() && formHasMethod(args.caller(), identifierstr(M)))
 {
        formRunObject = args.caller();
        formRunObject.M();    
}

this code does not work in ax 2012 but it works fine in ax 2009.

 here  we have to create a class , a menu item as action   and then call this menu item in form's click method and then pass the value in the class through menu item and  catch the vaulue in the main method of class.

First create a form  demo form with a table called demo table where we will have only one field over there   and one grid in design and one button over there.



then create a class1


create a menu item with action type and assign the class to that.



then write the click method of that button as 

void clicked()
{
    //super();

    MenuFunction    mf;
    args            args = new Args();
    ;


    args.record(DemoTable);


    mf = new menufunction(identifierstr(MenuItem1), MenuItemType::Action);
    mf.run(args);
}

now open the form and insert a record and click the button you will get output as 


intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...