How to Set Data Type for Attribute of Composite Type?

Understanding basics of 1C:Enterprise platform. To start working with 1C:Enterprise platform visit Getting started page

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

In my document I have an attribute of composite type which consists of reference to catalog and string. Depending on type of document the form should let choose a catalog item in this field or input a text string. How can I set the default type for this field when the document type is changed?

 
#2
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 17, 2012
Company: Zoi TechCon GmbH

Code
   If TypeDoc = 1 Then
      TextBox = ""; // string
   ElsIf TypeDoc = 2 Then
      TextBox = Catalogs.Name.EmptyRef(); // ref
   EndIf

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

Wow! Thanks! That's what I needed.

 
#4
People who like this:0Yes/0No
Just came
Rating: 1
Joined: Apr 17, 2012
Company: Zoi TechCon GmbH

You are welcome! :)

 
#5
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jul 20, 2011
Company:

Hi, Xin Wang!

You can also use something like that:

Code
   If Object.IsCompany Then
      Items.Owner.TypeRestriction = New TypeDescription("CatalogRef.Companies");
   Else
      Items.Owner.TypeRestriction = New TypeDescription("CatalogRef.Counterparties");
   EndIf;

 
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.