I'm sorry to hear that your Cavalier has been so unwell. Constipation in dogs can occur for many reasons such as dehydration, change in diet, consumption of bones or indigestible objects. Also diseases of the gastrointestinal system, hormonal imbalance or even some heart disease medications can exacerbate or cause constipation.
Your veterinarian has diagnosed a heart murmur and will be able to recommend a specific diet that suits your dogs needs. It will depend on which (if any) heart medications your dog is on and why they developed constipation in the first place as well as their need for additional dental prophylaxis in the form of chews and dental dry food. Always remember that a dog consuming good quality dry food should always have access to water. The good news is that there are premium quality dry and wet foods that are more suited to dogs that develop constipation. These diets are prescription only and will need to be recommended by your veterinarian.
Best of luck finding the perfect food, your pooch will certainly thank you for it!