How do I change the motion reference in an animation state during runtime?

I tried this solution: How to change animation clips of an animator state at runtime? Is there a way? - #4 by WoofyWyzpets

But this doesn’t work if I try to use a different animation clip. I also want to reuse the same state for swapping different animation clips but this just changes animation clip and not the motion state.

Is there better solution?

So the motion field you are talking about is the actual animation being played. What exactly are you trying to do? Why is switching from one animation to another not what you are looking at?