2. Test Module Predefined Data

For students who study 1C Junior course.

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Oct 7, 2020
Company: ABK Teknik İmalat ve Mühendislik Çözümleri

Hello, I was solving the Test Of the Second Module Of the Junior Developer Course.
I think, I did what was requested in step 5. But when I test the program, I get the same error in step 5.

I attached screenshot of the error, Expense document Form and ExpenseType catalog as an attachment

Can you help me?

The request: Create the Other predefined element of the ExpenseTypes Catalog.
If a user forgets to specify the expense type for the Expense document, it should be automatically set to Other.


These my codes belong that in Document Expense: Document Form:

Code
&AtServerNoContext
Function ExpenseTypesOther()
   Return Catalogs.ExpenseTypes.Other;
EndFunction

&AtClient
Procedure FillingExpenseTypeWithOther()
   For Each Line In Object.Details Do
      If Line.ExpenseType.IsEmpty() Then
         //MyMessage = "ExpenseType is null!!";
         //Raise MyMessage;
         Line.ExpenseType = ExpenseTypesOther();
      EndIf;
   EndDo;   
EndProcedure


&AtClient
Procedure BeforeClose(Cancel, Exit, MessageText, StandardProcessing)
   FillingExpenseTypeWithOther();
EndProcedure

&AtClient
Procedure DetailsAmountOnChange(Item)
   FillingExpenseTypeWithOther();
EndProcedure

&AtClient
Procedure BeforeWrite(Cancel, WriteParameters)
   FillingExpenseTypeWithOther();
EndProcedure

&AtClient
Procedure DetailsDescriptionOnChange(Item)
   FillingExpenseTypeWithOther();
EndProcedure




And my codes belong that in Document Expense: Object Module:


Code
&AtServer
Function ExpenseTypesOther()
   Return Catalogs.ExpenseTypes.Other;
EndFunction

Procedure OnWrite(Cancel)
   For Each CurRowDetails In Details Do
      If CurRowDetails.ExpenseType.IsEmpty() Then
         //MyMessage = "ExpenseType is null!!";
         //Raise MyMessage;
         CurRowDetails.ExpenseType = ExpenseTypesOther();
      EndIf;
   EndDo;
EndProcedure

Procedure BeforeWrite(Cancel, WriteMode, PostingMode)
   
   ThisObject.Total = 0;
   For Each CurRowDetails In Details Do
      ThisObject.Total = ThisObject.Total + CurRowDetails.Amount;
      If CurRowDetails.ExpenseType.IsEmpty() Then
         //MyMessage = "ExpenseType is null!!";
         //Raise MyMessage;
         CurRowDetails.ExpenseType = ExpenseTypesOther();
      EndIf;
   EndDo;
      
EndProcedure

Edited: Hüseyin Karademir - Oct 23, 2020 11:00 AM
 
#2
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Dec 6, 2019
Company: 1C Innovation Vietnam

Hi Huseyin,

In the document form, you should set the expense for the whole catalog (Object.ExpenseType) instead of the expense type in the tabular section

 
#3
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Oct 7, 2020
Company: ABK Teknik İmalat ve Mühendislik Çözümleri

Thank you Dang,

I edited this function that you say but in the OnWrite() and BeforeWrite() Procedure in the Document Expense: Object Module.

And it works.

However firstly, I edited the funtion in the Document Form but it did not work and also edited in the Object Module and it works.

Code
      If ThisObject.ExpenseType.IsEmpty() Then
         ThisObject.ExpenseType = ExpenseTypesOther();
      EndIf;

 
Subscribe
Be the first to know tips & trick 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.