Whether that “fix” will work or not depends on what error your gearbox has recorded. There is a common problem with dried grease on the PNP switch which it often will help with. Better to read the codes to know what you’re dealing with. There may be other problems developing as well.
See, for example, this thread where the fix helped but a loose connector might have been becoming a problem as well
https://www.volvoforums.org.uk/showthread.php?t=336049