Picture update porblem

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Apr 10, 2020
Company: HerSüreçYazılım

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

 
#2
People who like this:0Yes/0No
Administrator
Rating: 23
Joined: Oct 3, 2019
Company:

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

 
#3
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Apr 10, 2020
Company: HerSüreçYazılım

Hello Aleksandr,

Thank you for your help.

Note: Version 8.2 (8.3.15.1869)

 
#4
People who like this:0Yes/0No
Administrator
Rating: 23
Joined: Oct 3, 2019
Company:

Not at all :)

Did you succeed?

 
#5
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Apr 10, 2020
Company: HerSüreçYazılım

Problem solved. Thank you again.

 
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.