In two dimensions, we can turn every inexact differential $f(x,y)dx+g(x,y)dy$ into an exact version by multiplying both functions $f(x,y)$ and $g(x,y)$ by an additional function $I(z)$, i.e. $I(z) f(x,y) dx + I(z) g(x,y) dy = 0$, where $z = xy$. Then, the condition that the cross-derivatives should be the same, i.e.
$$f_y(x,y) I(z) + x I'(z) f(x,y) = g_x(x,y) I(z) + y I'(z) g(x,y),$$
lead to a differential equation for $I$ and therewith to the solution.
Is this trick of multiplying the inexact differential by an additional function also possible in higher dimension, i.e. for $n$ variables? In other words, is there a possibility to make $\sum_{i=1}^n a_i(x) dx_i$ exact, where $a_i(x)$ are arbitrary $C^1$-functions? An idea would be
$$\sum_{i=1}^n a_i(x) \sum_{k=1}^n I_{ik}(x_i x_k) dx_i$$
to account for the cross-derivatives. Is this solveable for $I_{ik}$ or are there other approaches? Does anybody has experiences therefore? Thanks already.