Let's start with the design of your view. You mentioned that it contains three tables, including HcmWorker. Doesn't it mean that if there is work item with three workers, your view returns three rows? If so, where do you want to put the list of worker names? If you want your view returning a single record (with all worker names concatenated in a single field), then the structure of your view is wrong. You either need to changes this view, or you can use it as a data source for another view doing the aggregation.
Regarding your code, please start by compiling your code and fixing compilation errors.
Your code is trying to get a list of Name field values for a given worker, which looks wrong for several reasons:
- HcmWorker table doesn't have any Name field.
- You're finding HcmWorker by its Worker field, but such a field doesn't exist either.
- There would be a single Name only, therefore trying to create a comma-separated list from it doesn't make a sense.
Please test your SQL code before writing X++ generating this code.
Also, look at what you put into expression variable - you'll immediately see a problem. You forgot to provide values for all the parameters (%1, %2, $3, $4).
Another problem is that you're returning an empty string. I assume you wanted to return expression.