How to check if a project contains custom field in workflow
Custom Field can be applied to selected projects, but might not all projects. The issues could be the parent/child of the other issues in different projects.
If ProjectA/B/C are assigned a custom field, for example, MyField, but ProjectX does not (which could be new created or just add one issue as child of issue in ProjectA). Then the workflow scripts might get runtime error while it would trying to go through all child issues to update the value of MyField.
I have tried project.fields.contains("MyField"), or for each fld in project.fields (but there is no fld.name or fld.getPresentation methods), also message(fld) will show something like "78-148", or "78-149", etc.
None of above works.
So how to check if a project contains a custom field ?
Please sign in to leave a comment.
Diegohb,
It is supported in JS-based Workflow API (i.e. in YouTrack since version 2017.3). To check if the project has a field you need to execute the following method: https://www.jetbrains.com/help/youtrack/incloud/v1-Project.html#findFieldByName. If there is no such a field in this project, `null` is returned.
Hello.
Unfortunately, currently workflow editor doesn't allow handle such cases.
Feel free to create feature request about such functionality.
Is this still not supported? Any plans to support it? I'm looking to create a rule that automatically figures out what version a new ticket should be assigned to... but i have to figure out how to iterate every possible version for the specific project...
would using http API to query youtrack project cusotm field bundles be the only solution ?
Thanks for the update!
How about iterating the values for that field?
It has a `values` property as well, which is an instance of Set. You may iterate over it with `forEach` method.