Swim bladder and constipation are two different problems, although a swim bladder problem may cause constipation.
Some fish, especially fancy goldfish with compressed bodies, are prone to swim bladder problems and sometimes nothing can be done. In a lot of cases it does not seem to bother the fish, as long as it can get to food.
If it a recently developed problem than I guess we can discount a genetic cause.
Fluctuations in temperature can also be a trigger as can a tumour of an organ near the swim bladder organ.
Parasitic or bacterial infections are two other possibilities.
Often diet is the cause. What are you feeding? Try offering live foods only for a few days and see if that helps.
Make sure the diet is varied. You could also try dried food that has been soaked in medicinal paraffin oil, glycerol or castor oil.