I'm working on Microsoft AX 2012. I have weird problem, I got list page with 5 records from VendTrans table. I have created a method for getting Dimension on VendTrans table in my form Data Sources.
public display DimensionValue getDimensionValue(VendTrans _vendTrans)
{
dimAttrValueSet = DimensionAttributeValueSet::find(VendTrans.DefaultDimension);
select dimAttrValueSetItem
where dimAttrValueSetItem.DimensionAttributeValueSet == dimAttrValueSet.RecId
join dimAttrValue
where dimAttrValue.RecId == dimAttrValueSetItem.DimensionAttributeValue
join dimAttribute
where dimAttribute.RecId == dimAttrValue.DimensionAttribute
&& dimAttribute.Name == 'NAME';
return dimAttrValue.getValue();
}
On my form I have created a field. Data Source is set to VendTrans (table) and DataMethod is set to "getDimensionValue".
And now after changing chosen record on my list page, this field is refreshing for all records.
For example my dimension value for 1st record is "AAA" and for 2nd record is "BBB". When 1st record is chosen this field value for all 5 records would be "AAA". After chosing 2nd record value is "BBB" for all 5 records.
It's clear that I want value for every record in a field for it, without any refresh afther changing records ...
You have two problems:
_vendTrans.DefaultDimension
instead of VendTrans.DefaultDimension
in line 3.To fix both move the method to the VendTrans
table to enable caching:
[SysClientCacheDataMethodAttribute(true)]
public display DimensionValue getDimensionValue()
{
dimAttrValueSet = DimensionAttributeValueSet::find(this.DefaultDimension);
...
}