Method
findOne — finds a record on a specific entity by searching with field value.
Description
Minimum number of arguments for this method is three. The first argument is the entity name and the other two are Field Alias – Field Values pair that will filter the result. The Field Alias can be a unique identifier field and the Field Value is its value.
This method says “Find lead with email equal to john.smith@gmail.com” where lead is the entity, email is the field alias followed by the value. This method will return one record that matches the defined filters.
Structure of the method:
findOne('Entity Name', 'Field Alias', 'Field Value')
Parameters
The first argument is always Entity Name like for example “lead” or “contact”. You can add as many pair arguments as you want.
Examples
#Sample 1 {% set lead = findOne('lead','email', 'john.smith@gmail.com') {{lead.id}} //Output: the id of the record {{lead.first_name}} //Output: John {{lead.email}} //Output: john.smith@gmail.com #Sample 2 with pair field alias, field value {% set lead = findOne('lead','status', 'New', 'source', 'Pending') Id: {{lead.id}} Name: {{lead.first_name}} Email: {{lead.email}} //Output: Will output the id, first_name, email of the first record found.
To stay updated with the latest features, news and how-to articles and videos, please join our group on Facebook, Flexie CRM Academy.