Let $\omega = 2xz dy\wedge dz + dz\wedge dx -(z^2 + e^x)dx\wedge dy$. We have just started out with differential forms and need to find a one-form $\lambda$ so that $d\lambda = \omega$.
\begin{gather} \lambda = a_1dx + a_2dy + a_3dz\\ d\lambda = da_1\wedge dx + da_2\wedge dx + da_3\wedge dx \end{gather}
I just cant figure out suitable functions $a_i$. I tried guessing $\lambda$ but I would like to know how to find $\lambda$ in general.
Recall that for a function $f(x, y, z)$, $df = \dfrac{\partial f}{\partial x}dx + \dfrac{\partial f}{\partial y}dy + \dfrac{\partial f}{\partial z}dz$. So we have
\begin{align*} d\lambda &= da_1\wedge dx + da_2\wedge dy + da_3\wedge dz\\ &= \left(\frac{\partial a_1}{\partial x}dx + \frac{\partial a_1}{\partial y}dy + \frac{\partial a_1}{\partial z}dz\right)\wedge dx\\ &\ + \left(\frac{\partial a_2}{\partial x}dx + \frac{\partial a_2}{\partial y}dy + \frac{\partial a_2}{\partial z}dz\right)\wedge dy\\ &\ + \left(\frac{\partial a_3}{\partial x}dx + \frac{\partial a_3}{\partial y}dy + \frac{\partial a_3}{\partial z}dz\right)\wedge dz\\ &=\frac{\partial a_1}{\partial x}dx\wedge dx + \frac{\partial a_1}{\partial y}dy\wedge dx + \frac{\partial a_1}{\partial z}dz\wedge dx\\ &\ + \frac{\partial a_2}{\partial x}dx\wedge dy + \frac{\partial a_2}{\partial y}dy\wedge dy + \frac{\partial a_2}{\partial z}dz\wedge dy\\ &\ + \frac{\partial a_3}{\partial x}dx\wedge dz + \frac{\partial a_3}{\partial y}dy\wedge dz + \frac{\partial a_3}{\partial z}dz\wedge dz\\ &= \frac{\partial a_1}{\partial y}dy\wedge dx + \frac{\partial a_1}{\partial z}dz\wedge dx\\ &\ + \frac{\partial a_2}{\partial x}dx\wedge dy + \frac{\partial a_2}{\partial z}dz\wedge dy\\ &\ + \frac{\partial a_3}{\partial x}dx\wedge dz + \frac{\partial a_3}{\partial y}dy\wedge dz\\ &= -\frac{\partial a_1}{\partial y}dx\wedge dy + \frac{\partial a_1}{\partial z}dz\wedge dx\\ &\ + \frac{\partial a_2}{\partial x}dx\wedge dy - \frac{\partial a_2}{\partial z}dy\wedge dz\\ &\ - \frac{\partial a_3}{\partial x}dz\wedge dx + \frac{\partial a_3}{\partial y}dy\wedge dz\\ &= \left(\frac{\partial a_3}{\partial y} - \frac{\partial a_2}{\partial z}\right)dy\wedge dz\\ &\ + \left(\frac{\partial a_1}{\partial z} - \frac{\partial a_3}{\partial x}\right)dz\wedge dx\\ &\ + \left(\frac{\partial a_2}{\partial x} -\frac{\partial a_1}{\partial y}\right)dx\wedge dy. \end{align*}
Therefore, you need to find functions $a_1, a_2, a_3$ such that
\begin{align*} \frac{\partial a_3}{\partial y} - \frac{\partial a_2}{\partial z} &= 2xz\\ \frac{\partial a_1}{\partial z} - \frac{\partial a_3}{\partial x} &= 1\\ \frac{\partial a_2}{\partial x} -\frac{\partial a_1}{\partial y} &= -z^2 - e^x. \end{align*}
There are infinitely many solutions to this system of differential equations, you just need to find one. I don't know of a systematic way of doing this, but here's how I'd do it.
The second equation seems simplest, so let's start with that. To make things easier, let's see if we can find a solution with $a_3(x, y, z) = 0$. In this case $a_1(x, y, z) = z$ is one possible solution to the second equation. For this choice of $a_1$, the third equation reduces to $\frac{\partial a_2}{\partial x} = -z^2 - e^x$ and so $a_2(x, y, z) = -xz^2 -e^x$ is a solution. As these choices of $a_1, a_2, a_3$ also satisfy the first equation, we see that they are a solution to the system. Therefore
$$\lambda = zdx - (xz^2 + e^x)dy$$
is a one-form with $d\lambda = \omega$.
What would I have done if the choices I had made did not lead to a solution of the system? Go back and try again, this time making less restrictive assumptions. As Jyrki Lahoten mentions in the comments to the question, you can always take one of the coefficient functions to be zero as I did above. Why? Well, if $\lambda = a_1dx + a_2dy + a_3dz$ is a solution to $d\lambda = \omega$, and $f$ is a function such that $\frac{\partial f}{\partial z} = -\lambda_3$, then
$$\lambda' := \lambda + df = \left(a_1 + \frac{\partial f}{\partial x}\right)dx + \left(a_2 + \frac{\partial f}{\partial y}\right)dy$$
and $d\lambda' = d\lambda + ddf = \omega + 0 = \omega$ so $\lambda'$ is another solution where the coefficient of $dz$ is zero. Therefore, we can assume that the coefficient of $dz$ in the solution we're looking for is zero. Note, there is nothing special about $dz$ here, we can also find solutions where the coefficient of $dx$ is zero, and solutions where the coefficient of $dy$ is zero.