Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > how to add item's image?

Forum

Search UsersRules
how to add item's image?
#1
Just came
Points:: 0
Joined:: Sep 21, 2014

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.

Profile
#2
Guest
Points::
Joined::

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.

Profile
#3
Just came
Points:: 0
Joined:: Sep 21, 2014

Thank you  ;)

Profile
#4
Just came
Points:: 0
Joined:: Sep 21, 2014

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.

Profile
#5
Guest
Points::
Joined::

Hello, Odilbek!

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

Profile
#6
Just came
Points:: 0
Joined:: Sep 7, 2020

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

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.