T
T
Timofey Tkachev2020-06-24 11:19:08
Bitrix24
Timofey Tkachev, 2020-06-24 11:19:08

Change the value of a custom field in Bitrix24 when creating a new task?

I'm trying to change the value of a custom field through the onBeforeTaskAdd event, standard fields are easy to change, but not custom fields. I got the arFields array before saving it and the value I need is present in the array. After saving, this value is reset to the preset value.
I need: in the "list of sections of the infoblock" field, select the id of the infoblock through the script in init.php, which I successfully do and write it (id) into the value of the task field.
It's simple, but it doesn't work...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Nikolaev, 2020-06-25
@gromdron

1) In the "Binding to infoblock sections" type field, you cannot specify the ID of the infoblock.
The infoblock ID is selected when creating a field for the task entity, and when creating the task itself, only section IDs are specified.
2) The OnBeforeTaskAdd event takes as an output parameter $arFields, an associative array of fields for the task being created.
By specifying an event handler, are you explicitly passing that you are receiving it by reference? there is a very big difference
between and 3) Handlers are built in such a way that they are called sequentially. There is a possibility that another handler following yours overwrites your value
function handleBeforeTaskAdd( $arFields )
function handleBeforeTaskAdd( &$arFields )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question