Switching places with a summoned creature takes place before enemy attacks, unlike a normal move. However, creatures with a maximum range on their attacks decide whether they can attack based on the distance to your old position, not the distance to your new position. Thus, after switching places, you can get hit by a ranged attack that travels one square further than its normal range.
For example, in the genie battle, stand one square above the lowest square near the door (where the genie normally can't hit you), and switch places with a summoned Ambassador below you next to the door; after you move the genie may throw a fireball at you despite normally not having enough range to hit that lowest square.