Overleaf is not really an issue: Overleaf is just a nice web interface for maintaining .tex-input-files. For compiling documents Overleaf uses the TeX distribution TeX Live. In the menu of Overleaf you can select which TeX Live release to use for compiling (TeX Live 2023, TeX Live 2022, TeX Live 2021 etc.)
With \DTLforeach* every iteration is done within its own local scope/group.
With the \DTLforeach*-loop you might need to toplevel-expand the macros which are placeholders for entries in the fields of database records.
As you did not deliver a minimal complete compilable reproducible and verifiable example, I cannot judge whether every iteration being done in its own local scope does matter.
If the local scope doesn't matter, you can probably do
\newcommand\PassFirstToSecond[2]{#2{#1}}%
\DTLforeach*{testDb}% database label
{\enabled=To Test,\latest=Latest,\testName=Test Name, \reference=Reference}
{% call each iteration:
\expandafter\PassFirstToSecond\expandafter{\reference}{%
\expandafter\PassFirstToSecond\expandafter{\testName}{%
\expandafter\PassFirstToSecond\expandafter{\latest}{%
\expandafter\PassFirstToSecond\expandafter{\enabled}{%
\testDefine
}%
}%
}%
}%
}%
Or
\DTLforeach*{testDb}% database label
{\enabled=To Test,\latest=Latest,\testName=Test Name, \reference=Reference}
{% call each iteration:
\expanded{%
\unexpanded{\testDefine}%
{\unexpanded\expandafter{\enabled}}%
{\unexpanded\expandafter{\latest}}%
{\unexpanded\expandafter{\testName}}%
{\unexpanded\expandafter{\reference}}%
}%
}
If the local scope does matter, you can probably accumulate stuff in a
scratch-token-register:
\newcommand\PassFirstToSecond[2]{#2{#1}}%
\newtoks\scratchtoks
\csname @ifdefinable\endcsname\stopromannumeral{\chardef\stopromannumeral=`\^^00}%
\global\scratchtoks={}%
\DTLforeach*{testDb}% database label
{\enabled=To Test,\latest=Latest,\testName=Test Name, \reference=Reference}
{% call each iteration:
\global\scratchtoks\expandafter=\expandafter{%
\the\expandafter\scratchtoks
\romannumeral
\expandafter\PassFirstToSecond\expandafter{\reference}{%
\expandafter\PassFirstToSecond\expandafter{\testName}{%
\expandafter\PassFirstToSecond\expandafter{\latest}{%
\expandafter\PassFirstToSecond\expandafter{\enabled}{%
\stopromannumeral\testDefine
}%
}%
}%
}%
}%
}%
\the\scratchtoks
Or
\newcommand\PassFirstToSecond[2]{#2{#1}}%
\newtoks\scratchtoks
\global\scratchtoks={}%
\DTLforeach*{testDb}% database label
{\enabled=To Test,\latest=Latest,\testName=Test Name, \reference=Reference}
{% call each iteration:
\global\scratchtoks\expandafter=\expandafter{%
\the\expandafter\scratchtoks
\expanded{%
\unexpanded{\testDefine}%
{\unexpanded\expandafter{\enabled}}%
{\unexpanded\expandafter{\latest}}%
{\unexpanded\expandafter{\testName}}%
{\unexpanded\expandafter{\reference}}%
}%
}%
}%
\the\scratchtoks
Or accumulate stuff in a scratch-macro:
\newcommand\PassFirstToSecond[2]{#2{#1}}%
\newcommand\scratchmacro{}%
\csname @ifdefinable\endcsname\stopromannumeral{\chardef\stopromannumeral=`\^^00}%
\gdef\scratchmacro{}%
\DTLforeach*{testDb}% database label
{\enabled=To Test,\latest=Latest,\testName=Test Name, \reference=Reference}
{% call each iteration:
\xdef\scratchmacro{%
\unexpanded\expandafter\expandafter\expandafter{%
\expandafter\scratchmacro
\romannumeral
\expandafter\PassFirstToSecond\expandafter{\reference}{%
\expandafter\PassFirstToSecond\expandafter{\testName}{%
\expandafter\PassFirstToSecond\expandafter{\latest}{%
\expandafter\PassFirstToSecond\expandafter{\enabled}{%
\stopromannumeral\testDefine
}%
}%
}%
}%
}%
}%
}%
\scratchmacro
Or
\newcommand\PassFirstToSecond[2]{#2{#1}}%
\newcommand\scratchmacro{}%
\gdef\scratchmacro{}%
\DTLforeach*{testDb}% database label
{\enabled=To Test,\latest=Latest,\testName=Test Name, \reference=Reference}
{% call each iteration:
\xdef\scratchmacro{%
\unexpanded\expandafter\expandafter\expandafter{%
\expandafter\scratchmacro
\expanded{%
\unexpanded{\testDefine}%
{\unexpanded\expandafter{\enabled}}%
{\unexpanded\expandafter{\latest}}%
{\unexpanded\expandafter{\testName}}%
{\unexpanded\expandafter{\reference}}%
}%
}%
}%
}%
\scratchmacro
expandafterandunexpandedam I missing some documentation? I like this documentation for xparse, but i have not been able to find it for ´expanded, expandafter, unexpanded, etc..` – Malle Nov 23 '23 at 08:45\expandedis a primitive of the LuaTeX engine.\unexpandedwas already introduced with e-TeX.. Overleaf provides a table where you can see which TeX-engine extending Knuthian TeX brings along which primitives.. – Ulrich Diez Nov 23 '23 at 14:52\expandafteryou might be interested in How can I know the number of expandafters when appending to a csname macro?. Regarding the different stages of TeX's processing of input you might be interested in Define commands without the need for brackets and in Conversion of space characters into space tokens. – Ulrich Diez Nov 23 '23 at 14:57