i think that if you are going to derive with respect to something containing x then you can't treat anything containing that x as it is a funtion of it
to derive this you just need to make a simple substitution
let: $\alpha=$$\sin(3x) $$\Leftrightarrow x=$$\frac13$$\arcsin($$\alpha)
$
then the function becomes in terms of $\alpha$ as:
$f($$\alpha)=$$\alpha^4 + $4($\frac13$$\arcsin($$\alpha))² + $$3g($$\frac13$$\arcsin($$\alpha$))
which now you can derive easily with the power and chain rule to get:
$\frac{d}{d\alpha}f(\alpha)=4\alpha^3 + \frac{8}{9}\frac{\arcsin(\alpha)}{\sqrt{1-\alpha²}} + \frac{g'(\frac{1}{3}\arcsin(\alpha))}{\sqrt{1-\alpha²}}$
now you can try and substitute $\sin(3x)$ back in to get:
$\frac{d}{d\sin(3x)}f(x)=4\sin(3x)^3 + \frac{8}{9}(\frac{3x}{\sqrt{1-\sin²(3x)}}) + \frac{g'(x)}{\sqrt{1-\sin²(3x)}}$
you can also make it look a little better by replacing $\sqrt{1-\sin²(3x)}$ with $\cos(3x)$
and that's it