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');
}
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