Search your query

Thursday, July 24, 2025

Rename SQL Database (AxDB) to other name after bacpac file import (After Restoring UAT DB to Development Server)

 > Some cases, we might have issue with renaming Database once we import from UAT server to DEV server. In order to rectify this, we need to execute the following commands in SQL SERVER.


-- RENAME DATABASE ONE TO ANOTHER IN SQL SERVER.


-- Set Database in Single User Mode:

ALTER DATABASE AxDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE


-- Try to Rename the Database:

ALTER DATABASE AxDB MODIFY NAME = AxDB_Initial_Backup_15072025


-- Set the Database to Multi User Mode:

ALTER DATABASE AxDB_Initial_Backup_15072025 SET MULTI_USER WITH ROLLBACK IMMEDIATE


Tuesday, July 1, 2025

X++ code to fetch the Project total cost value from Project WBS based on Project ID

 X++ code to fetch Project total cost value from Project WBS based on Project ID


public static AmountMST findProjectWBSTotalCostValue(ProjTable _projTable)

{

    ProjTable                                       projTableLocal;

    AmountMST                                   totalWBSCost;

    PSAActivityEstimates                    projectActivityEstimates;

    SmmActivityParentLinkTable         activityParentLinkTable;

    SmmActivities                              smmActivities;


    if  (_projTable)

    {

        while select activityNumber from smmActivities

            exists join activityParentLinkTable

            where activityParentLinkTable.ActivityNumber == smmActivities.ActivityNumber

            exists join projTableLocal

            where projTableLocal.RecId == activityParentLinkTable.refRecId &&

                  activityParentLinkTable.parentType == smmActivityParentType::Project &&

                  projTableLocal.ProjId == _projTable.ProjId

        {

            while select projectActivityEstimates

            where projectActivityEstimates.ActivityNumber == smmActivities.ActivityNumber

            {

                    totalWBSCost += projectActivityEstimates.TotalCostPrice;

            }

        }

    }

    return totalWBSCost;

}