Substitute Value into Catalog Form Item

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 5
Joined: Sep 27, 2011
Company:

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.

 
#2
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Sep 16, 2011
Company: individual

Why do you use this line?
AreaField = String(Object.Area);
It makes types not match, use
AreaField = Object.Area;

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.