R
R
Roman2019-01-14 19:13:26
1C-Bitrix
Roman, 2019-01-14 19:13:26

How to find out which fields were changed when the OnAfterIBlockSectionUpdate event was called?

The task is to perform some actions when changing the infoblock section, only if its name has been changed. I know that it is possible to save the state when the OnBeforeIBlockSectionUpdate event is called. Is there an alternative?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2019-01-14
@roman94

You don't need to save anything.
When the OnBeforeIBlockSectionUpdate event fires, get the fields (from the parameters of the handler function). These are new values. You already know how to get the old ones: CIBlockSection::GetByID().
It turns out that your task is reduced to a banal condition in the handler:

$oldFields = \CIBlockSection::GetByID($fields["ID"])->GetNext();
if($fields["NAME"] != $oldFields["NAME"]) {...}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question