catalyst / moodle-tool_dataflows

A generic workflow and processing engine which can be configured to do a large variety of tasks.
GNU General Public License v3.0
12 stars 9 forks source link

Obtaining values for custom fields in a dataflow #878

Open mikecarruthers26 opened 8 months ago

mikecarruthers26 commented 8 months ago

I have created a dataflow triggered on a course completed event. I can get the data from the user and course, but the custom fields exist in an array: customfields:

How can I write an expression to obtain the value of the custom field with name = 'cms_id'. if I use custom fields[2].value this assumes that the second field will always be cms_id but that's not the case.

Is there any documentation on the valid functions that may be used in an expression?

brendanheywood commented 7 months ago

The expressions language is from symphony:

https://symfony.com/doc/current/reference/formats/expression_language.html

There is a bunch of additional functions which have been made available inside expressions here:

https://github.com/catalyst/moodle-tool_dataflows/blob/MOODLE_401_STABLE/classes/local/provider/expression_provider.php#L76-L85

You might be able to filter this as-is using an array operator:

https://symfony.com/doc/current/reference/formats/expression_language.html#array-operators

If neither of those work and you need to pull in a php level function and expose it then that should be an easy pull request