TheWriterFantastic™
Explorer
Must occur prior to the damage? Yes. Must occur prior to additional effects? That's unclear.
The game does not have an established timeline of resolution that gives us discrete steps such as:
1. Roll attack.
2. Determine if attack is a hit by comparing result to AC.
3. Roll damage.
4. Reduce damage if able
5. Apply damage to hit point total.
6. Apply other effects of successful hit.
but specifically not:
2. Determine if attack is a hit by comparing result to AC.
3. Apply any non-damage effects of a successful hit.
4. Roll damage.
5. Reduce damage if able.
and so forth.
That lack of specificity in general process means that any interaction has to be made specific, for example the specification of shield that it applies it's bonus against the attack that created the opportunity for its casting, or it is unclear. Or, to phrase that differently; implicit timing = unclear timing.
See my prior postings of the steps of an attack, as taken from the Basic Rules in #73, and as I quoted ProphetSword quoting the PHB in #81.
In step 3 of Making an Attack, it's laid out as attack roll, on a hit, determine damage and then any additional effects as indicated by the attack. As it's laid out, described in making an attack as additional effects would imply that the effects either occur at the same time as damage, or afterwards -- otherwise, it would be described as apply effects and any additional damage. Granted, again, that's my ruling at my table -- your ruling at yours might be different, as it is your prerogative, but the spirit of the rules seem to indicate that the if the rogue sees the attack coming and know's it is going hit, he can roll with the damage using Uncanny Dodge. Sure, he's still going to take something of a zap from Shocking Grasp, which will leave the rogue fuzzy enough to lose any subsequent reactions until the next turn, but it shouldn't prevent the use of Uncanny Dodge, as the attack triggers off the determination of the hit, which is subsequently followed by damage and effects. Similarly, Shield is cast by a caster knowing the attack is going to hit, whether it be a confirmed attack roll or a Magic Missile, and as the caster sees it coming, as a reaction instantaneously throws up a temporary shield of force in the attack's path, potentially blocking it.
Other reactions that trigger off damage without being indicated as an interrupting reaction would be prevented by Shocking Grasp, but Uncanny Dodge and Shield both trigger off of the determination of a hit, prior to resolution of damage. But again, your table, your ruling.