Friday, February 22, 2019

Validate WrkCtrId AX 2012/D365

Below are some example to understand Relations between Route, Resource and Resource group tables in AX 2012/D365

if(routeWrkCtrId != "" &&  routeWrkCtrId != _wrkCtrIdToValidate)
    {
        select firstOnly wrkCtrResourceGroupResourceRoute
            where wrkCtrResourceGroupResourceRoute.WrkCtrId == routeWrkCtrId;

        select firstOnly wrkCtrResourceGroupResource
            where wrkCtrResourceGroupResource.WrkCtrId == _wrkCtrIdToValidate;

        if(wrkCtrResourceGroupResource.ResourceGroup != wrkCtrResourceGroupResourceRoute.ResourceGroup)
        {
            throw error(strFmt('@TTT214',WrkCtrResourceGroup::find(wrkCtrResourceGroupResourceRoute.ResourceGroup).WrkCtrId));
        }
    }
    //If resource group is attached to selected opration, validate that selected resource should fall under that resource group.
    else if(prodRoute.activityRequirementSet().resourceGroupRequirement().RecId)
    {
        //retrive operation resource group.
        routeWrkCtrId = prodRoute.activityRequirementSet().resourceGroupRequirement().WrkCtrId;

        select firstOnly wrkCtrResourceGroupResource
                where wrkCtrResourceGroupResource.WrkCtrId == _wrkCtrIdToValidate;

        if(prodRoute.activityRequirementSet().resourceGroupRequirement().RecId != wrkCtrResourceGroupResource.ResourceGroup)
        {
            throw error(strFmt('@TTT214',routeWrkCtrId));
        }
    }
    else
    {
        throw error('@TTT216');
    }

No comments:

Post a Comment

Happening

Upgrade from AX 2012 to Latest Dynamics 365 Finance and Operation

Below are the steps defined by sequence. 1. Create new Upgrade project in Dynamics LCS. 2. Create VSTS Project and connect it with L...

Trending now