I messed around with something similar when I wanted to add heated mirrors from a '99 to my '97. I bought the mirror at the junkyard, and the full door harness thinking I can just replace the '97 harness with the '99, and have the connector for the mirror heater.
No such luck - the two harnesses are completely different, as are the connectors that mate to the vehicle under the dash. You'll spend a lot of time trying to re-splice the '99 to work in the '97 vehicle.
Your best bet is probably to swap the entire harness from the old '97 door into the new '99 door. It may be a decent amount of work, so you may be better off trying to find a '97 door instead.
I only had to run one additional wire for the mirror heater, so I ran it in parallel to the main harness:
I didn't use the harness I got with the '99 mirror, I just took it apart to use as a source of wires:
__________________
1997 4Runner Limited 4WD E-Locker ~200k | Falken Wildpeak A/T3W 265/75/16 | Pro Comp 69 16x8 | OME 2906 | B&M 70264
Addicted Offroad Front Bumper | Spiker Engineering High-Lift Hood Struts and Ultragauge Mount