Filters and function
Filters
DataPress (Dataverse Integration) provides several Dataverse-specific and general purpose Twig filters.
formatted_value( attributeName )
-- returns the formatted value of the filtered entity record as reported by Dataverse. Returns the entity record attribute value if no formatted value available.
E.g.record|formatted_value( "preferredappointmenttimecode" )
to_entity_reference
-- converts an Entity object, or an EntityReference-like object to a strongly typed EntityReference object. For an EntityReference-like object, the filter expectsLogicalName
(required),Id
andName
keys.
E.g.record|to_entity_reference
or{ "LogicalName": "contact", "Id": "00000000-0000-0000-0000-000000000000" }
add_query( queryName, queryValue )
-- adds a GET query argument to the filtered URL, honors the already existing query string which allows piping.wpautop
-- see WordPress wpautop() docs.
Functions
image_url
image_url()
- returns URL to the image stored in the specified Dataverse image column.
- image_url(
record,
column,
isThumb,
{
"Content-Disposition": "inline",
"Content-Type": "text/html; charset=utf-8",
"Cache-Control": "max-age=604800"
}
)
file_url
file_url()
- returns download URL for the file stored in the specified Dataverse file column.
- file_url(
record,
column,
{
"Content-Disposition": "inline",
"Content-Type": "text/html; charset=utf-8",
"Cache-Control": "max-age=604800"
}
)
last_error
last_error()
- returns last error generated by the Twig provider.
entity_url
entity_url( record, postId = null )
-- returns URL to the website page with the given entity record bound to it. Uses Table Binding feature. If more than one WordPress post is bound to the table, you can pass post ID to link to a different page instead.
retrieve_multiple
retrieve_multiple()
- retrieve Dataverse records using Web API twig functions
Parameters:
entity: This specifies the name of the entity from which records are being retrieved. In this case, the entity is contact.
select: A list of the fields to be returned for each record. Here, the columns specified are fullname and ownerid.
filter: This parameter is used to filter the records based on specified value.
order: Specifies the ordering of the returned records. The key is the column logical name and the value is the sort direction.
expand: Used to include related entities or additional data from related entities in the results. This parameter can help fetch detailed information from linked entities. Other examples:
- parentcustomerid_account($select=name,telephone1,accountid)
- transactioncurrencyid($select=isocurrencycode).
top: Limits the number of records returned. Here, it is set to 2, meaning only the top 2 records will be returned.
includeCount: This should be a boolean value. If set to true, the total record count can be retrieved using {{ records.TotalRecordCount }}
. In this example, it is set to null, meaning the count is not included.
skip: Specifies the records to skip. It is set to null here, meaning no records are skipped.
skipToken: Used for pagination. When set to null, it indicates there is no token used for skipping records.
retrieve
retrieve()
- retrieve a single Dataverse record using Web API twig functions
Parameters:
entity: This specifies the name of the entity from which records are being retrieved.
select: A list of the fields to be returned for a record.
guid: This parameter is used to filter the record by id.
expand: Used to include related entities or additional data from related entities in the results. This parameter can help fetch detailed information from linked entities. Other examples:
- parentcustomerid_account($select=name,telephone1,accountid)
- transactioncurrencyid($select=isocurrencycode).