Answer the question
In order to leave comments, you need to log in
After changing the character code in the OnBeforeIBlockElementAdd event handler, the character code is not checked for uniqueness. Where to dig?
AddEventHandler("iblock", "OnBeforeIBlockElementAdd", Array("CustomFields", "OnBeforeIBlockElementAddHandler"));
class CustomFields
{
// создаем обработчик события "OnBeforeIBlockElementAdd"
function OnBeforeIBlockElementAddHandler(&$arFields)
{
$arFields["CODE"] = $arFields["CODE"]."_".date('dmY');
return;
}
}
Answer the question
In order to leave comments, you need to log in
That's right, checking the symbolic code of an infoblock element occurs before the OnBeforeIBlockElementAdd or OnBeforeIBlockElementUpdate events. This happens in bitrix/modules/iblock/classes/general/iblockelement.php (from lines 4128 to 4149)
If you want to change the character code to, then use the OnStartIBlockElementAdd event)
I suspect that you will have to do the validation in the handler by hand.
// делаем выборку элементов по новому символьному коду
// ...
if (//что-то нашлось) {
$APPLICATION->ThrowException('Элемент с таким символьным кодом уже существует');
return false;
}
And in setting up the infoblock, is it necessary to check for uniqueness?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question