Report and Client Custom Fields
Here are custom field for the Client and the Report. These are given a Label and a Value in PlexTrac. While it is not shown in PlexTrac, these are also given a Key based on the Label. For example if you added a custom field with the Label My Custom Field it would also make a key called my_custom_field. Keys are all lower case with underscores for spaces.
You can access these fields in different ways depending on what data you need.
Note: This section is under construction and may be incomplete.

Single Field Reference

If you only need one Report or Client custom field the easiest way to pull that data is as follows:
1
REPORT CUSTOM FIELD
2
{%p if 'my_custom_field' in REPORT_INFO.fields and 'value' in REPORT_INFO.fields['my_custom_field'] %}
3
{{ REPORT_INFO.fields['my_custom_field'] }}
4
{{ REPORT_INFO.fields['my_custom_field'].label }}
5
{{ REPORT_INFO.fields['my_custom_field'].value }}
6
{%p endif %}
7
8
CLIENT CUSTOM FIELD
9
{%p if 'my_custom_field' in CLIENT_INFO.fields and 'value' in CLIENT_INFO.fields['my_custom_field'] %}
10
{{ CLIENT_INFO.fields['my_custom_field'] }}
11
{{ CLIENT_INFO.fields['my_custom_field'].label }}
12
{{ CLIENT_INFO.fields['my_custom_field'].value }}
13
{%p endif %}
14
15
RESULTS
16
{'label': 'My Custom Field', 'value': 'My Custom Field Value'}
17
My Custom Field
18
My Custom Field Value
Copied!

Iterative Fields Reference with Keys

You can also iterate through all the custom fields in either a Report or a Client. This might be helpful to set all the labels and values to variables which you can call later in the template, or if you don’t know the names of the custom fields.
In this example we iterate through the list keys(). This list contains all the keys for each custom field.
1
REPORT CUSTOM FIELD
2
{%p for key in REPORT_INFO.fields.keys() %}
3
Key: {{ key }}
4
Label: {{ REPORT_INFO.fields[key].label }}
5
Value: {{ REPORT_INFO.fields[key].value }}
6
{%p endfor %}
7
8
CLIENT CUSTOM FIELD
9
{%p for key in CLIENT_INFO.fields.keys() %}
10
Key: {{ key }}
11
Label: {{ CLIENT_INFO.fields[key].label }}
12
Value: {{ CLIENT_INFO.fields[key].value }}
13
{%p endfor %}
14
15
RESULTS
16
Key: my_custom_field
17
Label: My Custom Field
18
Value: My Custom Field Value
Copied!

Iterative Fields Reference with Items

In this example we iterate through the list items(). The key, value means we’re assigning to things from the items() list. the item key is assigned to key and the label, value fields are assigned to value.
1
REPORT CUSTOM FIELDS
2
{%p for key, value in REPORT_INFO.fields.items() %}
3
Key: {{ key }}
4
Looped Value: {{ value }}
5
Label: {{ value['label'] }}
6
Value: {{ value['value'] }}
7
{%p endfor %}
8
9
CLIENT CUSTOM FIELDS
10
{%p for key, value in CLIENT_INFO.fields.items() %}
11
Key: {{ key }}
12
Looped Value: {{ value }}
13
Label: {{ value['label'] }}
14
Value: {{ value['value'] }}
15
{%p endfor %}
16
17
RESULT
18
Key: my_custom_field
19
Looped Value: {'label': 'My Custom Field', 'value': 'My Custom Field Value'}
20
Label: My Custom Field
21
Value: My Custom Field Value
Copied!

Macro for Displaying Custom Fields

You can also put the above knowledge to use in a macro.
1
{%p macro display_report_field(key, label) %}
2
{%p for field in REPORT_INFO.fields %}
3
{%p if key == field and REPORT_INFO.fields[key].value and label != "" %}
4
{{ label }}: {{ REPORT_INFO.fields[key].value }}
5
{%p elif key == field and REPORT_INFO.fields[key].value %}
6
{{ REPORT_INFO.fields[key].value }}
7
{%p elif key == field %}
8
{{ key }} Report Field is missing a value
9
{%p endif %}
10
{%p endfor %}
11
{%p endmacro %}
12
13
CALL MACRO
14
{{p display_report_field("my_custom_field","My Custom Field") }}
15
16
RESULT
17
My Custom Field: My Custom Field Value
18
or
19
My Custom Field Value
20
or
21
my_custom_field Report Field is missing a value
Copied!
Last modified 7mo ago