Constipation/ milk of Magnesia/ 2nd trimester

I am 13 weeks 5 days and struggling with constipation and stomach pains as result from it. I got the green light from Doctor that it was ok to take milk of magnesia only when needed. I have taken it and it does work, but every time I am going to take it I am afraid it will hurt the baby. Do any of you take it? Is it safe?