Invalid field 'tx.language'
I'm hitting an api error on production and staging sites but oddly not the 'same' local dev site when I try to access the message template admin page.
Note that the api call fails in api explorer an in message admin extension.
I haven't re-written this for readability but the abbreviation tx
means 'translation'.
Note the cache has had several days to age out & has been cleared using System.flush & the UI method
CRM.api4('MessageTemplate', 'get', {
select: ["id", "msg_title", "is_default", "is_active", "tx.language:label", "tx.language"],
join: [["Translation AS tx", "INNER", ["tx.entity_table", "=", "'civicrm_msg_template'"], ["tx.id", "=", "id"]]],
groupBy: ["tx.language"],
where: [["workflow_name", "IS NOT EMPTY"]],
limit: 25
}).then(function(messageTemplates) {
// do something with messageTemplates array
}, function(failure) {
// handle failure
});
backtrace
/civicrm/Civi/Api4/Query/Api4SelectQuery.php(655): CRM_Core_Error::backtrace("backTrace", TRUE)
#1
//civicrm/Civi/Api4/Query/Api4SelectQuery.php(600): Civi\Api4\Query\Api4SelectQuery->getField("tx.language", TRUE)
#2 //civicrm/Civi/Api4/Query/Api4SelectQuery.php(378): Civi\Api4\Query\Api4SelectQuery->getExpression("tx.language")
#3 /civicrm/Civi/Api4/Query/Api4SelectQuery.php(152): Civi\Api4\Query\Api4SelectQuery->buildGroupBy()
#4 //civicrm/Civi/Api4/Query/Api4SelectQuery.php(164): Civi\Api4\Query\Api4SelectQuery->getSql()
#5 //civicrm/Civi/Api4/Generic/DAOGetAction.php(111): Civi\Api4\Query\Api4SelectQuery->run()