How to assign value to catalog item description

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Just came
Rating: 1
Joined: May 26, 2012
Company:

How to assign comment of selected enum item in the form to catalog item description?

 
#2
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

I would do it by script at OnChange event handler of Enum Attribute, like so

Code
&AtClient
Procedure AttributeEnum1OnChange(Item)
   Object.Description = GetCommentOfEnum(Object.AttributeEnum1);
EndProcedure

&AtServer
Function GetCommentOfEnum(pEnum)
   nameOfEnum = "SomeEnum";
   
   For each iEnum In Metadata.Enums[nameOfEnum].EnumValues Do
      If Enums[nameOfEnum][iEnum.Name] = pEnum Then
         return iEnum.Comment;
      EndIf;
   EndDo;
EndFunction

 
#3
People who like this:0Yes/0No
Just came
Rating: 1
Joined: May 26, 2012
Company:

Thanks!

Any other way to get the Enum comment other than going over each Enum item in a cycle? The enumeration is pretty big

 
#4
People who like this:1Yes/0No
Just came
Rating: 1
Joined: May 26, 2012
Company:

I actually figured out it myself:

Code
&AtServer
Function GetCommentOfEnum(pEnum)
      nameOfEnum = "HTML5_Tags";
   
      EnumIndex = Enums[nameOfEnum].IndexOf(pEnum); 
   iEnum = pEnum.Metadata().EnumValues[EnumIndex];
   Return iEnum.Comment;
     
EndFunction

 
#5
People who like this:0Yes/0No
Active user
Rating: 7
Joined: Sep 26, 2012
Company: individual

Yes, your variant better

 
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.