0

All of my custom report mail_report jobs give this error, both through cron and when triggered manually:

"Did not find valid instance to execute"

The report is defined as

class com_foo_bar extends CRM_Report_Form {

It is stored as an extension in

[civicrm.files]/ext/custom

For example, report 70 works fine in a webbrowser .. it is at

https://mydomain.com/bla/civicrm/report/instance/70

But the mail_report job log says

Entity: Job Action: mail_report Summary Finished execution of yyy with result: Failure, Error message: Report Mail Triggered... Did not find valid instance to execute Details

Parameters raw (from db settings): instanceId=70 format=csv

Parameters parsed (and passed to API method): a:3:{s:7:"version";i:3;s:10:"instanceId";s:2:"70";s:6:"format";s:3:"csv";}

Full message: Finished execution of yyy with result: Failure, Error message: Report Mail Triggered... Did not find valid instance to execute

The same happens when called from the command line. If job.mail_report is called on a regular report, it returns results. But if it is called on my custom reports, it returns

$ drush -u cron civicrm-api job.mail_report instanceId=70 format=csv sendmail=0 
Report Mail Triggered...                                                                                                                                                                             [error]
Did not find valid instance to execute
Array
(
    [is_error] => 1
    [error_message] => Report Mail Triggered...
Did not find valid instance to execute
)

or

$ php bin/cli.php -s mydomain.com -u cron -p XXXXXX -e Job -a mail_report --instanceId=70 --format=csv --sendmail=0
Report Mail Triggered...
Did not find valid instance to execute
Died during callApi

Any ideas ?

2
  • can you cross check that instanceId and format parameter on separate line for instance id 70? Mar 6, 2020 at 10:02
  • You can see from the details it is parsed correctly - but also, when calling from the command line cli.php, both calls are 100% the same apart from the instanceId.
    – commonpike
    Mar 9, 2020 at 8:50

1 Answer 1

1

What doesn't help, is that the code for Report.php:402

https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Utils/Report.php#L402

requires

if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) {

and otherwise

  $is_error = 1;
  // ...
  $messages[] = 'Did not find valid instance to execute';

The 'name' reported for my custom report is more like

com.foo.bar

.. is that a bug, or some requirement I missed ?

2
  • 1
    Did you create it with civix or manually? For use with the standard extension autoloader it would end up in a subfolder CRM/Myextension/Form/Report/SomeReport.php and be called CRM_Myextension_Form_Report_SomeReport. So yes in a sense it's currently required to have Form in it, but it probably shouldn't be, and it shouldn't be enforced the way it is with strstr().
    – Demerit
    Apr 29, 2020 at 19:10
  • @demerit thanks for your response. I made them manually; CiviX didn't exist at the time I made those ... funny the problem only arises in the mail, not in the report online.
    – commonpike
    Apr 30, 2020 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.