Undo the wiring harness that's inside your B-pillar and do one of two things:
1. repair the wiring breaks I suspect are there or
2. replace it with a more intact one.
I've done both rear harnesses on my 91 318i sedan with salvage yard finds and am glad to report windows and door locks work at least 95 percent of the time.
The point of failure both times was frayed/broken wiring inside the rubber grommet between the B-pillar and the rear door.
Adios for now,