Let us refine the document register records by excluding any tabular section rows that contain services.
- In Designer, right-click the Services document and then click Open object module.
This opens the Services document module. - Add a condition to the handler of the Posting event, to the beginning of the loop that iterates through the tabular section rows, after the following line:
For Each CurRowMaterialsAndServices In MaterialsAndServices Do
The resulting procedure should look as shown in listing 10.4.
Listing 10.4. The Services document records
Procedure Posting(Cancel, Mode) //{{__REGISTER_REGISTERRECORDS_WIZARD // This fragment was built by the wizard. // Warning! All manually made changes will be lost next time you use the wizard. // register BalanceOfMaterials Expense RegisterRecords.BalanceOfMaterials.Write = True; For Each CurRowMaterialsAndServices In MaterialsAndServices Do If CurRowMaterialsAndServices.MaterialOrService.MaterialServiceType = Enums.MaterialServiceTypes.Material Then Record = RegisterRecords.BalanceOfMaterials.Add(); Record.RecordType = AccumulationRecordType.Expense; Record.Period = Date; Record.Material = CurRowMaterialsAndServices.MaterialOrService; Record.Warehouse = Warehouse; Record.Quantity = CurRowMaterialsAndServices.Quantity; EndIf; EndDo; //}}__REGISTER_REGISTERRECORDS_WIZARD EndProcedure
The added script excludes the tabular section rows where the item type is not Material from the loop. Let us examine this in detail.
In each loop step the CurRowMaterialsAndServices variable contains the data of the current row of the MaterialsAndServices tabular section.
The MaterialOrService column name specified after a dot (CurRowMaterialsAndServices.MaterialOrService) calls a reference to the material or service item stored in the current tabular section row.
The MaterialServiceType specified after a dot (CurRowMaterialsAndServices.MaterialOrService.MaterialServiceType) calls the MaterialServiceType attribute of this item of the MaterialsAndServices catalog.
The comparison operator (=) compares the obtained value with the Material value of the MaterialServiceTypes enumeration (Enums.MaterialServiceTypes.Material).
If the values match, the operators included in the loop are executed. Otherwise the next loop iteration, which processes the next tabular section row, is started.
Next page: In 1C:Enterprise mode