Answer the question
In order to leave comments, you need to log in
The values of the custom field of the section with the "List" type in 1C-Bitrix do not change. Why?
Good afternoon. I had a problem when working with the Bitrix API. I added a new custom field to the sections of the infoblock with the "List" type and added 3 values to it with IDs 4,5,6, respectively. Since initially it will not be possible to select a value from the list for all sections that already exist, so I decided to select all sections of the infoblock and go through each of them, updating the user field UF_***. I read in the API that in order to change a property with the "List" type, you need to set the id of the field in this list to the array value. In my case, I want to mark a field in the list with id = 4. The result is something like this:
$arFilter = array(
'IBLOCK_ID' => 4,
);
$arSelect = array(
'ID',
'CODE',
'IBLOCK_ID',
'NAME',
'UF_CHOOSE_RULE'
);
$dbSection = CIBlockSection::GetList(array(), $arFilter, false, $arSelect);
while( $arSection = $dbSection-> GetNext() ){
$sections[] = $arSection;
}
//print_r($sections);
$bs = new CIBlockSection;
foreach ($sections as $k => $sec) {
$bs->Update($sec['ID'], array('UF_CHOOSE_RULE' => '6'));
}
Answer the question
In order to leave comments, you need to log in
Found a solution:
$bs->Update(ID_РАЗДЕЛА, array('UF_CHOOSE_RULE' => array(
'VALUE' => 6
)))
Most likely, he just screwed up something with the names / values \u200b\u200bout of carelessness.
Update just one element (attempt). Look at what the Update method returned. If false, then you look at the error in $bs->LAST_ERROR. Everything, the usual debug, it is necessary to create questions for the sake of this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question