A broker who, pursuant to a contract in writing entered into after October 1, 1997, has earned and is owed a fee or commission with respect to a lease or upon the exercise of an option for renewal or expansion of the lease, whether payable over time or in a lump sum, from the owner of commercial real estate pursuant to such written contract for the broker's services in connection with a lease of commercial real estate, shall have a cause of action to enforce the contract with respect to the fee or commission against a subsequent owner, even though the subsequent owner is not a party to the contract, if and only if the subsequent owner has notice of the contract as provided in this part with respect to the fee before obtaining title to the commercial real estate. There shall be no prohibition against a broker giving the notice as required by this part, and any such prohibition is void and unenforceable.