S
S
Sergey2021-03-17 07:51:04
PHP
Sergey, 2021-03-17 07:51:04

How to find field IDs in custom_fields in amocrm?

I add a deal to UNPARSED from the form, and in the contact of the deal I need to specify the phone, but in all the examples that I found, the field ID is indicated, but how can I find out this ID?
I also need to specify the order address, email and order details (product/material, quantity).
Here's my code:

// Create a new ticket in the unparsed when added from a web form
$incomingLead = new AmoIncomingLeadForm();

// Set required parameters
$incomingLead->setIncomingLeadInfo([
'form_id' => 1,
'form_page' => ' https://site.com ',
'form_name' => 'Test ticket'
]);

// Adding deal parameters
$lead = new AmoLead([
'name' => 'New order from the site'
]);
$lead->setCustomFields([ 25475362 => '#1543252' ]);
$incomingLead->addIncomingLead($lead);

// Add contact parameters
$contact = new AmoContact([
'name' => 'Hans-Dietrich Genscher'
]);
$contact->setCustomFields([
255114 => ,
'value' => '[email protected]',
'enum' => 'WORK'
]]
]);
$incomingLead->addIncomingContact($contact);

// Add company parameters
$incomingLead->addIncomingCompany([
'name' => 'Freie Demokratische Partei'
]);

// Save the ticket
$incomingLead->save();

A deal is created in the unparsed, but the phone and email are naturally not saved, because. id is invalid. How can I find out these id?

PS And is it possible to do without adding a company in my case? You only need to save contact information and order details.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2021-03-17
@sslion

Thanks for your input, but I figured it out myself.
All the necessary IDs can be found by requesting account information indicating with.
I have so:

print_r(AmoAPI::getAccount($with = 'custom_fields'));

M
mityayka1, 2021-03-17
@mityayka1

The company can not be created or added. In addition to id, amo fields can also be accessed by code, which is optional when creating fields (by api). The "phone" field in the contacts has this code "PHONE", try contacting through it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question