Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Picture update porblem

Forum

Search UsersRules
Picture update porblem
#1
Active user
Points:: 0
Joined:: Apr 10, 2020

Hello,
I'm adding a picture to the form. When you call the record, the picture is displayed. The picture disappears when updating the record.


&AtServer
Procedure AfterWriteAtServer(CurrentObject, WriteParameters)

If Not IsBlankString(PictureAddress) Then
Picture = GetFromTempStorage(PictureAddress);
PictureAddress = PictureAddress;
CurrentObject.Resim = New ValueStorage(Picture)  ;
CurrentObject.Write();
EndIf;

EndProcedure

Profile
#2
Administrator
Points:: 0
Joined:: Oct 3, 2019

Hello Ertuğrul,

please let me know which version of the 1C platform are you using?


In general, it's undesirable to use the "AfterWriteAtServer" Event to write additional object attributes...

If we want to save some additional attributes of the object while  writing, it's better to use the "BeforeWriteAtServer" Event for this.

In your case, the source code will look like this:

Code
&AtServer
Procedure BeforeWriteAtServer(Cancel, CurrentObject, WriteParameters)
   
   If IsTempStorageURL(PictureAddress) Тогда
       CurrentObject.Resim = New ValueStorage(GetFromTempStorage(PictureAddress));
   EndIf;   
   
EndProcedure



For the image to be displayed when the form is opened, don't forget about the "OnCreateAtServer" event:

Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   
   PictureAddress = GetURL(Object.Ref, "Resim");   
   
EndProcedure

Profile
#3
Active user
Points:: 0
Joined:: Apr 10, 2020

Hello Aleksandr,

Thank you for your help.

Note: Version 8.2 (8.3.15.1869)

Profile
#4
Administrator
Points:: 0
Joined:: Oct 3, 2019

Not at all :)

Did you succeed?

Profile
#5
Active user
Points:: 0
Joined:: Apr 10, 2020

Problem solved. Thank you again.

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.