web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / Tajwal's Blog / Delete Not Yet Acquired Fix...

Delete Not Yet Acquired Fixed Asset.

Community Member Profile Picture Community Member

while user from Fixed Asset department wanted to delete not yet acquired fixed asset he was receiving below error in Dynamics AX 2012 R2 CU7.

A financial dimension value is based on the AID067285 record and has been used on a  transaction. You cannot delete the AID067285 record

Cause : the error is because of AssetTable Delete Method its checking asset if it exists in DimensionAttributeLevelValue table using below ocde, will throw the error.

public void delete()
{
// Check to see if the associated dimension attribute value has been used
// in a way that would prevent deletion.
//my code to be added here this.deleteFinancialDimensions();

//system code checking fixed asset in DimensionAttributeLevelValue
if (!DimensionValidation::canDeleteEntityValue(this))
{
throw error(strFmt(“@SYS134392”, this.AssetId));
}

solution : to delete not yet acquired fixed asset, use below code in delete method of asset to delete it from DimensionAttributeLevelValue and DimensionAttributeValueCombination then from asset tables,

private void deleteFinancialDimensions()
{
DimensionAttributeLevelValue LevelValue,deleteValue;
DimensionAttributeValue atrValue;
DimensionAttribute dimAttribute;
DimensionAttributeValueCombination valueCombination;
DimensionAttributeValueGroup dimAttributeValueGroup;
DimensionHierarchy dimHierarchy;

TableId entityId;
RecId entityInstance;
DataAreaId dataAreaId;
RecId financialTagCategoryId;
;

[entityId, entityInstance, dataAreaId, financialTagCategoryId] = DimensionEnabledType::getFieldsForDeleteOrRename(this,0);

select firstonly RecId from LevelValue
exists join atrValue where
atrValue.RecId == LevelValue.DimensionAttributeValue &&
atrValue.EntityInstance == entityInstance &&
atrValue.IsDeleted == false
exists join dimAttribute where
dimAttribute.RecId == atrValue.DimensionAttribute &&
dimAttribute.BackingEntityType == entityId
exists join dimAttributeValueGroup where
dimAttributeValueGroup.RecId == LevelValue.DimensionAttributeValueGroup
notExists join dimHierarchy where
dimHierarchy.RecId == dimAttributeValueGroup.DimensionHierarchy &&
dimHierarchy.StructureType == DimensionHierarchyType::Focus;

if(LevelValue)
{
delete_from deleteValue where deleteValue.RecId == LevelValue.Recid;
}

delete_from valueCombination
where valueCombination.DisplayValue == this.AssetId
&& valueCombination.AccountStructure == 0
&& valueCombination.MainAccount == 0;
}


Filed under: Dynamics Ax 2012

This was originally posted here.

Comments

*This post is locked for comments