expression
take the opportunity to do something else; while you're at it
Used when doing something additional or different while already engaged in another activity. Often appears in the pattern ~のついでに.
See also: 物の序で
買い物に行くなら、ことのついでに郵便局にも寄ってきて。
If you're going shopping, stop by the post office while you're at it.
ことのついでに窓も拭いた。
I took the opportunity to wipe the windows too.
ついでに is a common adverb/conjunction meaning 'while you're at it' or 'incidentally', used more broadly. ことのついで is a noun phrase that often appears in the pattern ~のついでに, emphasizing the opportunity arising from a specific action.
物の序で is a similar expression meaning 'while you're at it' or 'taking the opportunity', but ことのついで is more common in modern usage.
From 事 (こと, 'thing, matter') + の (possessive particle) + 序で (ついで, 'order, opportunity'). The exact historical derivation is uncertain, but the phrase has been used since at least the Edo period to mean 'taking the opportunity of something'.