Wednesday, August 19, 2020

How to create SharedCategory And ProjectCategory in AX 2012 using X++

 Hi guys, Today we see How to create Shared Category And Project Category in AX 2012 using X++.

Just run the Below code on your job.

Make changes as per your requirement.


static void createProjectGroup(Args _args)

{

    SharedCategory    sharedCategory;

    CategoryTable     categoryTable;

    ProjCategory      projCategory;

    

    //shared category

    sharedcategory.categoryid='Truck';

    sharedcategory.categoryname='Truck';

    sharedcategory.insert();

    sharedcategory.canbeusedinproject(true,noyes::yes);


    if (sharedCategory.RecId)

    {

        categoryTable.CategoryId=sharedCategory.CategoryId;

        categoryTable.CategoryName=sharedCategory.categoryname;

        categoryTable.SharedCategory=sharedCategory.RecId;

        categoryTable.UseInProject=NoYes::Yes;

        categoryTable.insert();


    }


    if (categoryTable.RecId)

    {

        //Project Category

        projCategory.CategoryGroupId='Test';

        projCategory.CategoryType  = ProjCategoryGroup::find(projCategory.CategoryGroupId).CategoryType;

        projCategory.CategoryId=categoryTable.CategoryId;

        projCategory.Name=categoryTable.CategoryName;

        projCategory.TaxItemGroupId='All';

        projCategory.insert();

       projCategory.projLinePropertyIdEdit(true,projCategory,'Billable');

        info('New record created in ProjectCategory');

     }


}



Keep Daxing !!

No comments:

Post a Comment