Wednesday, October 18, 2017

Get unused Project categories In AX 2012

Below is the code for getting the unused project dimensions in AX.

Note : Please create a table(Test) with two string fields.


static void ProjCategory(Args _args)
{
    ProjUnpostedTransView   projUnpostedTransView;
    ProjPostTransView       projPostTransView;
    CategoryTable           categoryTable;
    Test           test;
    int iCounter;
    delete_from test;
    while select * from categoryTable
    {
        test.clear();
        select firstOnly projPostTransView where projPostTransView.CategoryId ==  categoryTable.CategoryId;
        if(projPostTransView)
        {
            continue;
        }
      //  else if(!projPostTransView)
      //  {
        select firstonly projUnpostedTransView where projUnpostedTransView.CategoryId ==  categoryTable.CategoryId;
        if(projUnpostedTransView)
        {
            continue;
        }
        else
        {
            test.AccountNum = categoryTable.CategoryId;
            test.Name = categoryTable.CategoryName;
            test.insert();
            iCounter++;
        }

SQL Query:

select * from CATEGORYTABLE where not exists
( select * from projPostTransView where CATEGORYTABLE.CategoryId =  projPostTransView.CategoryId) and 
not exists (select * from ProjLedgerJournalTransUnpostedView where CATEGORYTABLE.CategoryId =  ProjLedgerJournalTransUnpostedView.CATEGORYID)


@Rahul Talasila

No comments:

Post a Comment

Why do users often get confused about Dynamics 365 Customer Engagement (D365 CE), Dataverse, and the Power Platform?

  The Microsoft ecosystem for business applications can sometimes be difficult to navigate, especially when discussing Dynamics 365 Customer...