To retrieve Bitrix24 deals with multi-userfields containing at least one value, use the crm.deal.list method with specific filters and parameters. Here's how to implement this:
Step 1: Identify Multi-UserFields
First, determine which custom fields are configured for multiple values using crm.deal.userfield.list:
BX24.callMethod(
"crm.deal.userfield.list",
{
filter: { USER_TYPE_ID: "enumeration" } // Filters for list-type fields
},
function(result) {
if (result.error()) console.error(result.error());
else console.log("Multi-value fields:", result.data());
}
);
Look for fields with MULTIPLE: "Y" in their settings[7][8].
Step 2: Filter Deals by Non-Empty Multi-UserFields
Use the crm.deal.list method with a != "" filter on the target userfield:
BX24.callMethod(
'crm.deal.list',
{
filter: {
'!UF_YOUR_MULTI_FIELD': '' // Replace with your field code
},
select: ['ID', 'TITLE', 'UF_YOUR_MULTI_FIELD']
},
function(result) {
if (result.error()) console.error(result.error());
else console.log("Filtered deals:", result.data());
}
);
Replace UF_YOUR_MULTI_FIELD with your actual field code (e.g., UF_CRM_PRODUCTS)[1][6].
Key Notes:
- Field Codes: Userfields always start with
UF_ (e.g., UF_CRM_ORDER_ITEMS)[7].
- Multiple Values: The filter
!UF_FIELD: "" works for any userfield with at least one populated value, regardless of data type[3][6].
- Batch Processing: For large datasets, use pagination with
start: -1 and order: { ID: "ASC" }[1][6].
Example Response Structure
Successful requests return deals with:
{
"ID": "123",
"TITLE": "Sample Deal",
"UF_CRM_MULTI_FIELD": ["Value1", "Value2"]
}
Empty fields will be excluded from results[1][6].
This method ensures you efficiently retrieve deals with populated multi-userfields while leveraging Bitrix24's native filtering capabilities[1][3][6].