The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 2
Joined: Apr 2, 2025
Company:

I have a catalog "Product".

In Manager module I have defined handler to "PresentationGetProcessing" event. Here is the code,

Code
Procedure PresentationGetProcessing(Data, Presentation, StandardProcessing)   
   StandardProcessing = False;
   fullDescr = Data.Ref.FullDescr();
   Presentation = StrReplace(fullDescr, "/", ", ");      
EndProcedure


So, I am using custom presentation.

Now, I can easily create and change instances of product on ListForm but I am getting "No element selected!" error while deleting them. Deleting has become impossible. See the attached images.

So it is
Code
Data.Ref.FullDescr()
which causing the error.

How can this issue be solved?

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

Hi there!  

Before helping you, I’d like to understand what task you’re trying to solve with this line of code:  

Code
Presentation = StrReplace(fullDescr, "/", ", ");


So, you have products whose descriptions contain slashes, and when displaying these products to the user, you want to dynamically replace the slashes with commas. That makes sense.  

My question is — wouldn’t it be simpler to add another attribute to the Products catalog, where you store a transformed version of the description, already “cleaned” of slashes? You could fill this attribute, for example, when saving the object, using the same code:  

Code
Presentation = StrReplace(fullDescr, "/", ", ");



If I had to solve a similar task, that’s exactly how I would do it.  

Why? Let me show you.  

Let’s say we have a catalog with three products (Picture 1).

And we’ve written the following code in the Manager Module of the catalog (Picture 2)  

Now, turn on debugging and open the “Product” catalog interactively in 1C.  
You’ll easily notice that the PresentationGetProcessing procedure is called for every catalog item that the system displays in the list form.  

If there are only three products, that won’t affect performance much.  
But what if there are hundreds or thousands?  

In that case, each time the form is reopened, the system will execute this text replacement for every product — and eventually, that can negatively impact system performance.  

Whenever possible, it’s better to avoid writing code that could potentially slow down the system.  

Now, let’s get back to the error you’re encountering.  

First, one more recommendation: it is strongly NOT recommended to use the direct deletion mode in 1C (Picture 3)

It’s much better, if you really need to delete something, to use the “Toggle deletion mark” mode instead. Why? It’s simple.  

When you delete directly, 1C just removes the object from the database without checking whether there are any references to it elsewhere.  

For example, let’s say we’ve created an Invoice document that includes the product “Product 2” in its table part.  

Then, we go and directly delete that product from the catalog. As a result, we’ll end up with something like this (Picture 4).

You can see that the Invoice document still holds a reference to the product, but the product itself has been physically deleted from the database table.  

To avoid this kind of situation, it’s recommended to use “Toggle deletion mark.”  

When using that mode, the object isn’t immediately deleted — it’s only marked for deletion. The actual deletion happens later, when a service routine is run. (Picture 5)

At that time, the 1C platform checks referential integrity — meaning, if the product you’re trying to delete is still referenced in any documents, the platform won’t allow its removal.

Now, back to your specific error 🙂  

Set a breakpoint, start 1C in dialog mode, open the “Products” catalog, and try to directly delete one product.  

You’ll easily notice that when deleting, the PresentationGetProcessing procedure is called twice.  

In the first call, the object hasn’t yet been deleted from the database — it still has references. (Picture 6)


Press F5, and you’ll hit the second call. (Picture 7)

This time, the object has already been deleted from the database (on the server), but in the catalog’s list form, it still remains visible — and naturally, any attempt to access Data.Ref at that point will throw an error!  


So what’s the recommendation?  

It depends on your use case.

I would personally add another attribute and avoid direct deletion altogether.  

But if you still want to go with your current approach, you could do something like this:  

Code
Procedure PresentationGetProcessing(Data, Presentation, StandardProcessing)
    
    StandardProcessing = False;

    Try
        fullDescr = Data.Ref.FullDescr();
        Presentation = StrReplace(fullDescr, "/", ", ");       
    Except
    EndTry;
    
EndProcedure


However, this still wouldn’t be the best solution! 🙂

Download Scr_1.png (16.05 KB)
Download Scr_3.png (20.14 KB)
Download Scr_5.png (62.54 KB)
 
#3
People who like this: 0 Yes / 0 No
Administrator
Rating: 29
Joined: Oct 3, 2019
Company:

Pictures 6 and 7

Download Scr_6.png (44.54 KB)
Download Scr_7.png (43.43 KB)
 
#4
People who like this: 0 Yes / 0 No
Active user
Rating: 2
Joined: Apr 2, 2025
Company:

Dear Саша,

Thanks a lot for your detailed and comprehensive forensic analysis of the issue I’m dealing with. Everything you mentioned above is exactly what I’ve been speculating about.

It seems that the best practice is to use an attribute called “FullName”, though that might consume more memory if I end up having thousands of products.

However, one big question still remains: why did the developers even add the “PresentationGetProcessing” event if it causes so many problems, even when used as intended? This event is specifically designed to obtain an object’s “Presentation,” and “FullDescr” is a built-in method. So I believe I have every right to use both the event and the API as intended in my case with no errors guaranteed by the platform.

My verdict is that this case is tricky — a real dilemma

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

Dear Bahrom,

if you need to store some additional descriptions for a product, you can safely add new attributes to the catalog. This approach is used, for example, in standard 1C configurations. Please take a look at the screenshot — in the product card, there are fields like "Description", "Full Description", and "Details".

Both "Full Description" and "Details" have variable length, but this does not affect performance.

However, if you start “replacing” product names when displaying them to the user, this can potentially slow down the system...

 
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.