Wednesday 18 October 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

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...