MacOS Automator: Save new text file in current folder
Since you did not include your workflow, what type of workflow it is, or which version of OS X/macOS you're using, I can only offer an example of how you can set a variable to use for the Where: in a New Text File action in an Automator workflow.
I have a Temp folder, which I created, in the root the Macintosh HD, and in this folder I created two plain text files, named Filename1.txt and Filename2.txt, each of which contain a single line of text, "The name of this file is Filename1.txt" and "The name of this file is Filename2.txt", respectively.
The following Automator workflow works with selected Finder items in Finder's frontmost window, or the Desktop as appropriate if no other individual Finder windows are frontmost with a selection, and using a Run AppleScript action sets a variable to the parent folder of the first item selected to be used as the Where: in a New Text File action. and creates a file named Combined.txt.
Note in the image below, there is a break in the link between the Set Value of Variable action and what is the second Get Selected Finders Item action. This disconnect is created by selecting Ignore this action's input under Options in the second Get Selected Finders Item action.
The variable inputParentFolder
was dragged and dropped from the Variable section at the bottom of the workflow pane into the Where: in the New Text File action.
As you can see in the image below, the workflow completed successfully combining the content of the two selected files in Finder into a new file named Combined.txt in the same folder as the selected files.