E
E
Ex1st2021-07-05 12:53:04
1C-Bitrix
Ex1st, 2021-07-05 12:53:04

Custom fields in Bitrix CRM documents?

It is necessary to display the values ​​from the product properties in the sales receipt. I found this link , read it, made a custom field in the list of fields.

But I could not find the info, how to assign product properties to the created field? How to find out the ID of the product in the code so that any values ​​can be chained to it?

Here is the code how I added the field to the list of fields.

\Bitrix\Main\EventManager::getInstance()->addEventHandler('documentgenerator', 'onGetDataProviderList', 'orderReceiptGenerator');
function orderReceiptGenerator()
{
    \Bitrix\Main\Loader::includeModule('documentgenerator');

    class orderReceiptGenerator extends \Bitrix\DocumentGenerator\DataProvider implements \Bitrix\DocumentGenerator\Nameable
    {
        public function getFields()
        {
            return [
                'CODE' => [
                    'TITLE' => 'Код',
                    'VALUE' => function()
                    {
                        return 'test';
                    }
                ],
            ];
        }

        public function isLoaded()
        {
            return true;
        }

        public static function getLangName()
        {
            return 'Код';
        }
    }

    $result['orderReceiptGenerator'] = [
        'NAME' => 'Товарный чек (склад)',
        'CLASS' => 'orderReceiptGenerator',
        'MODULE' => 'documentgenerator',
    ];

    return $result;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2021-07-05
@rpsv

Take as a basis any available provider (in the bowels of the documentgenerator component, which are inherited from DataProvider) and see how they declare fields.
PS In the function to generate a class, this is of course great :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question