In this paper, we analyze the solvability of the optimal control problem for a nonlinear Schr\"{o}dinger equation. A Lions-type functional is considered as the objective functional. First, it is shown that the optimal control problem has at least one solution. Later, the Frechet differentiability of the objective functional is proved and a formula is obtained for its gradient. Finally, a necessary optimality condition is derived.