to be very effective, possibly in a surprising way = be completely successful or effective = to produce a desired result very easily and effectively: to work very well
Flattery usually works like a charm on him.
The new sales approach worked like a charm.
The cleaning fluid worked like a charm on the carpet stain.