Showing posts with label TABLE. Show all posts
Showing posts with label TABLE. Show all posts

Wednesday, August 22, 2018

ECORESCATEGORY Table in Dynamics-SSC -Vikas Mehta MULTISELECT

ECORESCATEGORY Table in Dynamics-SSC

Query to get the ecorescategory branches and nodes in ax 2012 

  this.parmQuery().dataSourceTable(tablenum(EcoResCategory), 1).clearRanges();
        categoryBuildRange = this.parmQuery().dataSourceTable(tablenum(EcoResCategory), 1).addRange(fieldnum(EcoResCategory, RecId));

        categoryEnum = category.getEnumerator();
        while (categoryEnum.moveNext())
        {
            categoryRecid = categoryEnum.current();
            select ecoResCategory where ecoResCategory.RecId == categoryRecid;
            currentLevel = ecoResCategory.Level;
            lowestlevel = ecoResCategory.getLowestLevel();
            categoryHierarchy = ecoResCategory.CategoryHierarchy;
            while(currentLevel <= lowestlevel)
            {
            while select ecoResCategoryChild where ecoResCategoryChild.CategoryHierarchy == categoryHierarchy
                                                && ecoResCategoryChild.Level ==  currentLevel
            {
                categoryRecid = ecoResCategoryChild.RecId;
                while select * from ecoResCat
                    order by ecoResCat.NestedSetLeft
                    where   ecoResCat.CategoryHierarchy == ecoResCategoryChild.CategoryHierarchy
                            && ecoResCat.NestedSetLeft  <= ecoResCategoryChild.NestedSetLeft
                            && ecoResCat.NestedSetRight >= ecoResCategoryChild.NestedSetRight
                {
                    if(ecoResCategory.RecId == ecoResCat.RecId)
                    {
                        select * from ecoResCategoryisLeaf
                            order by ecoResCategoryisLeaf.Name
                            where   ecoResCategoryisLeaf.CategoryHierarchy == ecoResCategoryChild.CategoryHierarchy
                             && ecoResCategoryisLeaf.ParentCategory  == ecoResCategoryChild.RecId
                                && ecoResCategoryisLeaf.IsActive == true;

                        if(!ecoResCategoryisLeaf)
                        {
                            allCategory.addEnd(categoryRecid);
                        }
                        break;
                    }
                }
            }
            currentLevel++;
        }


        }
 

Item lookup of ecorescategory in ui builder class

private void itemLookup(FormStringControl _control)
{
    Query query;
    QueryBuildDataSource qbdscategory,qbdsProductCategory,qbdsInvent,qbdsEcoProduct;
    container brandCon;
    int counter;
    RecId brandCategoryRecid,categoryRecid,segmentRecid;
    EcoResCategory category,segmentCategory;
    ;
    query = new query();
    qbdsInvent = query.addDataSource(tableNum(InventTable));
    qbdsEcoProduct = qbdsInvent.addDataSource(tableNum(EcoResProduct));
    qbdsEcoProduct.relations(false);
    qbdsEcoProduct.addLink(fieldNum(EcoResProduct,RecId),fieldNum(InventTable,Product));

    qbdsProductCategory = qbdsEcoProduct.addDataSource(tableNum(EcoResProductCategory));
    qbdsProductCategory.relations(false);
    qbdsProductCategory.addLink(fieldNum(EcoResProduct,RecId),fieldNum(EcoResProductCategory,Product));

    qbdscategory = qbdsProductCategory.addDataSource(tableNum(EcoResCategory));
    qbdscategory.relations(false);
    qbdscategory.addLink(fieldNum(EcoResProductCategory,Category),fieldNum(EcoResCategory,RecId));

 ECORESCATEGORY LOOKUP MULTISELECT

public void categoryLookup()
{
    Query           query = new Query(querystr(ProcCategoryEcoResCategory));
    int             mutiSelectTableNum = tablenum(EcoResCategory);

    container selectedFields = [mutiSelectTableNum, fieldname2id(mutiSelectTableNum, fieldstr(EcoResCategory, Name))];

    SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), categoryField.control(), query, false, selectedFields);
}

Tuesday, November 21, 2017

Delete Excess Data in Table TaxDocumentJson from SQL command in Microsoft Dynamics AX

Delete Excess Data in Table TaxDocumentJson from SQL command in Microsoft Dynamics AX


Remove the excess data in TaxDocumentJson at in AX HQ. Please carry this out on a UAT environment. Once this is tested successfully, you can do the same steps on Production.
Run the following SQL query to remove excess data
DECLARE @Deleted_Rows INT;
SET @Deleted_Rows = 1;
WHILE (@Deleted_Rows > 0)
  BEGIN
   BEGIN TRANSACTION
   -- Delete some small number of rows at a time
     DELETE TOP (10) j from taxdocumentjson j
inner join TaxDocumentRow r on r.TAXDOCUMENTJSON = j.ID;
SET @Deleted_Rows = @@ROWCOUNT;   
   COMMIT TRANSACTION
   CHECKPOINT -- for simple recovery model
END
You can count the number of the records required to be cleaned via another session to understand the progress
Select count(*) from taxdocumentjson j inner join TaxDocumentRow r on r.TAXDOCUMENTJSON = j.ID;

THE FIELD WITH ID '0' DOES NOT EXIST IN TABLE - SOLUTION :DYNAMICS AX X++ CODE

THE FIELD WITH ID '0' DOES NOT EXIST IN TABLE - SOLUTION :DYNAMICS AX X++ CODE 
ISSUE :
THE FIELD WITH ID '0' DOES NOT EXIST IN TABLE - SOLUTION.


SOLUTION:
YOU WILL GET THIS ERROR WHEN ONE OF THE FIELDS IS NOT MAPPED PROPERLY MOSTLY IN THE MAPS BEING USED.

Monday, April 18, 2016

CODE TO ADD A NOTE IN A DOCUMENT REFERENCE FOR A TABLE

CODE TO ADD A NOTE IN A DOCUMENT REFERENCE 
FOR A TABLE

static void TabledocuAdd(Args _args) {
DocuRef      docuRef;
VendTable vendTable;
vendTable = VendTable::find('123');
docuRef.RefCompanyId = vendTable.dataAreaId;
docuRef.RefTableId    = vendTable.TableId;
docuRef.RefRecId        = vendTable.RecId;
docuRef.TypeId        = 'Note';
docuRef.Name            = 'Imported';
docuRef.Notes         = 'This vendor was imported.';
docuRef.insert();

}

Friday, April 15, 2016

HOW TO DEBUG AX 2012 SSRS REPORT CODE BREAKPOINT SrsReportDataProviderPreProcess

HOW TO DEBUG AX 2012 SSRS REPORT 


1)   Open the DP class of the report.
2)  Extend SrsReportDataProviderPreProcess instead of SrsReportDataProviderBase
 in class declaration.
 Temp table properties should be

     (a) Table type : Regular instead of tempDB

     (b)  Created by : Yes

     (c) Created Transaction Id : Yes

Make sure  two checkboxes of user breakpoints and global breakpoints for debugging is enabled  in configuration .


AX FORM TABLE LOOKUP X++ CODE TABLE LOOKUP FORM LOOKUP

AX FORM TABLE LOOKUP X++ CODE TABLE LOOKUP FORM LOOKUP 


public void lookup()
{
 //   SysTableLookup sysTableLookup; // systemclass to create //customlookup
    Query query;
    QueryBuildDataSource qbd;
    SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(VIKASTable), this);
    ;
   // sysTableLookup = SysTableLookup::newParameters(tablenum(VIKASconfLocationTable));//_formcontrol);

    // Construct query on the table,
    // whose records you want to show as lookup.
    query = new Query();
    qbd = query.addDataSource(tablenum(VIKASTable));


    // add the fields to the lookup list
    sysTableLookup.addLookupfield(fieldnum(VIKASconfLocationTable,LocationID));
    sysTableLookup.addLookupfield(fieldnum(VIKASconfLocationTable,LocationName));

    // pass the query as parameter
    // system will show the records in the lookup
    // as per your query
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}


Form main datasource ka lookup
public void lookup(FormControl _formControl, str _filterStr)
{


   SysTableLookup sysTableLookup; // systemclass to create //customlookup
    Query query;
    QueryBuildDataSource qbd;
   // SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(VIKASTable), this);
    ;
    sysTableLookup = SysTableLookup::newParameters(tablenum(VIKASTable),_formcontrol);

    // Construct query on the table,
    // whose records you want to show as lookup.
    query = new Query();
    qbd = query.addDataSource(tablenum(Table)); 
    // add the fields to the lookup list
    sysTableLookup.addLookupfield(fieldnum(VIKASTable,Location));
   // sysTableLookup.addLookupfield(fieldnum(VIKASTable,LocationName));

    // pass the query as parameter
    // system will show the records in the lookup
    // as per your query
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

add table lookup in form
public void lookup(FormControl _formControl, str _filterStr)
{
    SysTableLookup              sysTableLookup;
    Query                              query;
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange             queryBuildRange;
    ;
    sysTableLookup  = SysTableLookup::newParameters(tablenum(EmplTable), _formControl);
    sysTableLookup.addLookupfield(fieldnum(EmplTable, EmplId));
    sysTableLookup.addLookupfield(fieldnum(EmplTable, legacyEmplId));
    sysTableLookup.addLookupMethod(identifierstr(name));
    query                              =  new Query();
    queryBuildDataSource    =  query.addDataSource(tablenum(EmplTable));
 
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

Related Posts Plugin for WordPress, Blogger...