how to add item's image?

The 1C:Enterprise developers forum

#1
People who like this:1Yes/0No
Just came
Rating: 0
Joined: Sep 21, 2014
Company:

I have ITEM (catalog) so i need to add item IMAGE, please, i do not have any experience with programming language 1C, if is it possible using without coding.

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Odilbek!

I'm glad to welcome you on 1C:Developer Network forums.

Would you please explain your task more precisely? If you would like to add a photo of a product for ITEM catalog items, you can see an example in 1C:Subsystems Library or 1C:Small Business.

The steps:

  • Add the Picture attribute for the catalog of ValueStorage type.
  • Add the PictureAddress form attribute of String type.
  • Add the ChangePicture command with Action and place it on the form.
  • Add OnCreateAtServer and AfterWriteAtServer event handlers for the form.
  • Add the following Script to the form module:
Code
&AtClient
Procedure ChangePicture(Command)
   BeginPutFile(New NotifyDescription("ChangePictureAfterPutFile", ThisForm), , , True, UUID);
EndProcedure

&AtClient
Procedure ChangePictureAfterPutFile(Result, Address, SelectedFileName, AdditionalParameters) Export
   If Result Then
      PictureAddress = Address;
   EndIf;
EndProcedure

&AtServer
Procedure AfterWriteAtServer(CurrentObject, WriteParameters)
   If Not IsBlankString(PictureAddress) Then
      Picture = GetFromTempStorage(PictureAddress);
      PictureAddress = PictureAddress;
      CurrentObject.Picture = New ValueStorage(Picture);
      CurrentObject.Write();
   EndIf;
EndProcedure


&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   If Not Parameters.Key.IsEmpty() Then
      CurrentObject = Parameters.Key.GetObject();
      PictureAddress = PutToTempStorage(CurrentObject.Picture.Get());
   EndIf;
EndProcedure


I have included a simplest example as a .cf file for you.

Download 1Cv8.cf (7.92 KB)
Download 1.png (106.08 KB)
Download 2.png (95.07 KB)
Download 3.png (153.02 KB)
 
#3
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Sep 21, 2014
Company:

Thank you  ;)

 
#4
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Sep 21, 2014
Company:

I'm using 1C:Enterprise 8.3 (8.3.1.531)

when i update database configuration i got this:

{Catalog.Item.Form.ItemForm.Form(3,21)}: Type is not defined (NotifyDescription)
  BeginPutFile(New <<?>>NotifyDescription("ChangePictureAfterPutFile", ThisForm), , , True, UUID); (Verification: Thin client)

thank you.

 
#5
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Odilbek!

Please update 1C:Enterprise platform to the latest version. As for now it is 8.3.5.1186.

 
#6
People who like this:0Yes/0No
Just came
Rating: 0
Joined: Sep 7, 2020
Company:

Hi, how to change this piece of code to work in "Information registers", cause information register can get this "Get()" method (specified in "On Create at server")
Thanks

 
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.