Answer the question
In order to leave comments, you need to log in
Can't add a custom field to a deal?
I have a code that adds a deal to amocrm through their php library,
I do everything according to the docs, but it gives an error
$externalData = [
[
'is_new' => true,
'name' => $title,
'tag' => $leadId,
'external_id' => '0752a617-c834-4bde-b4a6-76ff0fe26871',
]
];
$leadsCollection = new LeadsCollection();
foreach ($externalData as $externalLead) {
$lead = (new LeadModel())
->setName($externalLead['name'])
->setPrice($externalLead['price'])
->setTags(
(new TagsCollection())
->add(
(new TagModel())
->setName($externalLead['tag'])
)
)
->setRequestId($externalLead['external_id']);
$leadCustomFieldsValues = new CustomFieldsValuesCollection();
$textCustomFieldValuesModel = new TextCustomFieldValuesModel();
$textCustomFieldValuesModel->setFieldId(1200597);
$textCustomFieldValuesModel->setValues(
(new TextCustomFieldValueCollection())
->add((new TextCustomFieldValueModel())->setValue('Текст'))
);
$leadCustomFieldsValues->add($textCustomFieldValuesModel);
$lead->setCustomFieldsValues($leadCustomFieldsValues);
$leadsCollection = new LeadsCollection();
$leadsCollection->add($lead);
}
Answer the question
In order to leave comments, you need to log in
$leadCustomFieldsValues = new CustomFieldsValuesCollection();
$field= new TextCustomFieldValuesModel();
$field->setFieldId(010101);
$field->setValues(
(new TextCustomFieldValueCollection())
->add((new TextCustomFieldValueModel())->setValue("Text")
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question