This page details how to get all fields for the Deals module. You can request all fields for one of your modules, in this example we will send a request for all Deal fields. The response will include all standard and custom fields, along with the field information, such as the field name, field label, field type, if the field is required, if it is read only, and some other field security information.
// Snapforce API token
$api_token = 'your api token goes here';
// Snapforce username
$api_user = 'your username goes here';
// Module name
$module = "dealFields";
// Endpoint url
$url = "https://app.snapforce.com/prodigy/api/v1/request.php?module=$module&api_username=$api_user&api_token=$api_token";
// GET request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo 'Sending request...' . PHP_EOL;
$output = curl_exec($ch);
curl_close($ch);
// JSON decode returned deal object
$result = json_decode($output, true);
print_r($result);
Run the script:
$ php get_deal_fields.php
Sending request...
Array
(
[0] => Array
(
[type] => custom
[read_only] => 0
[field_level_security] => 3
[module] => Deals
[field_type] => Text
[field_label] => Email
[field_name] => custom_field6
[required] => 0
[linked_field] =>
[created_by] => 3
[date_time_created] => 2022-04-19 15:51:20
[last_modified_by] => 0
[timestamp] => 0000-00-00 00:00:00
)
[1] => Array
(
[type] => custom
[read_only] => 0
[field_level_security] => 3
[module] => Deals
[field_type] => DateTime
[field_label] => Date Created Custom
[field_name] => custom_field5
[required] => 0
[linked_field] =>
[created_by] => 2
[date_time_created] => 2022-02-24 18:48:09
[last_modified_by] => 0
[timestamp] => 0000-00-00 00:00:00
)
...
...
...