Suppose our force has expression as shown below:
$$ F = F_x \vec{i} + F_y \vec{j} + F_z \vec{k}$$
If a potential function $U$ exists then,
$$ F = -\nabla U = -[\frac{\partial U}{\partial x} \vec{i} + \frac{\partial U}{\partial y} \vec{j}+ \frac{\partial U}{\partial z} \vec{k}]$$
Now, you can compare any one of the coefficients, say we do $x$,
$$- \frac{ \partial U}{\partial x} = F_x$$
We can run a definite integral on both sides to get the potential:
$$ U = - \int F_x dx + h(y,z)$$
We need to include the extraneous $ h(y,z)$ term as all function of that form is differentiated to zero when derivated with $x$. Keeping it in their lets us fit the potential with other force components. So, we must find $h(y,z)$ such that the following system is satisfied:
$$ \begin{bmatrix} \frac{ \partial U}{\partial y} \\ \frac{ \partial U}{\partial z} \end{bmatrix} = - \begin{bmatrix} F_y \\ F_z \end{bmatrix}$$
Also, to check that a potential function exists, just need to check that force field is irrational that is:
$$ \nabla \times F = 0$$
For this case:
$$ ( \frac{ \partial}{\partial x} \vec{i} + \frac{ \partial}{\partial y} \vec{j} + \frac{ \partial}{\partial z} \vec{k}) \times (xy \vec{i}) $$
Doesn't seem this one is conservative 😥 This problem seems to be unsolvable unless you specify a path. Without a lack of context, I'd assume they mean a straight-line path.
On further thought: The force can be made to be conservative if assume that 'right' means the $ \vec{k}$ direction i.e:
$$ F= xy \vec{k}$$
Refer here for more information