Hello!
I have a catalog with two attributes: Area and AverageCost. And an information register with Area dimension and AverageCost resource. I need to display in catalog item form when the Area field is changed the AverateCost to be filled automatically.
I did the following:
- Created a common module AverageCostEvaluation
- Wrote a function in this module:
Function GetAverageCost(ContractDate, Area) Export
Filter = New Structure("Area", Area);
ResourceValues = InformationRegisters.AverageCostByAreas.SliceLast(ContractDate, Filter);
If ResourceValues.Count() = 1 Then
Return ResourceValues.AverageCost;
Else
Return 0;
EndIf;
EndFunction
In the catalog form module I wrote the following procedure:
&AtClient
Procedure AreaOnChange(Item)
ContractDate = CurrentDate();
AreaField = String(Object.Area);
Object.AverageCost = AverageCostEvaluation.GetAverageCost(ContractDate, AreaField);
EndProcedure
It produces no errors, but AverageCost field is not filled with value when Area is changed.
Thanks in advance.
The 1C:Enterprise developers forum