5

we are using Bitrix24 cloud version and created a custom field at CRM Deals.

How can I update this custom field (type:file) using Bitrix API?

Already tried :

$fileContent = file_get_contents(dirname(__FILE__)."/images/MM35_PG189a.jpg"); $batch = array( 'deal_update' => 'crm.deal.update?' .http_build_query(array( 'id' => 2, 'fields' => array( 'UF_CRM_1516125473' => array( 'filedata' => array( 'file.jpg', base64_encode($fileContent) ) ) ) )) ); $data = call($_SESSION["query_data"]["domain"], "batch", array( "auth" => $_SESSION["query_data"]["access_token"], "cmd" => $batch, )); 
1
  • did you ever manage to get this solved? Commented Sep 24, 2019 at 11:14

2 Answers 2

1

Error in variable name: filedata -> fileData

Sign up to request clarification or add additional context in comments.

1 Comment

It is hard to see the helpfulness of this answer. To improve that, use a little more prose. Also explaining why the very small difference in spelling is relevant would help a lot, including with the helpfulness for future/other readers.
0

@Ivan answer is exact, you simply have a typo in fileData attribute name.

Your code looks very similar to example in Bitrix documentation for crm.deal.update (example only on russian page version):

To update your custom field with type:file using Bitrix API, you should run sample code below. It will upload 100x100 px black square in PNG format.

BX24.callMethod("crm.deal.update", { id: 3, fields: { UF_CRM_1516125473: { fileData: [ "black-square-100x100.png", "iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQAAAABYmaj5AAAAAXNSR0IArs4c6QAAABNJREFUeNpjGAWjYBSMglFAVwAABXgAAUmp06QAAAAASUVORK5CYII=", ], }, }, params: { REGISTER_SONET_EVENT: "N" }, }); 

There is also some notes on File Processing in documentation.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.