Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obtaining values for custom fields in a dataflow #878

Open
mikecarruthers26 opened this issue Mar 13, 2024 · 1 comment
Open

Obtaining values for custom fields in a dataflow #878

mikecarruthers26 opened this issue Mar 13, 2024 · 1 comment

Comments

@mikecarruthers26
Copy link

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:
- { type: checkbox, value: '0', name: SpLD, shortname: submission_assignmentnotes }
- { type: text, value: KF123, name: cms_id, shortname: cms_id }
- { type: text, value: '62', name: volunteer_id, shortname: volunteer_id }
- { type: text, value: KF123, name: pun, shortname: pun }

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants