I recently spent some time figuring out how to use variables in the file extraction of a recurring delivery. I needed to have some conditional logic for a field in the file extraction.
I did not find this in any of the online docs so posting this for others
First note that workflow instance variables are not available during file extraction (I found this in this comment: Re: Use of variable in continuous delivery, how to do ? )
I created a delivery variable and used the syntax $(variables/@variableName) in the file extraction field expression but was still getting an error stating "Parameter of query 'variables/@variableName' is not defined in current context."
After a bit of trial and error I found that this syntax works in the field expression: $(variableName) No need to have the "variables" context as you do in other places of the delivery e.g. filename calculation.
Not sure why that is different, but I hope this helps anyone else wanting to use variables in a file extraction field expression.