Whenever a money judgment is sought for the balance due upon an obligation for the payment of which a deed of trust or mortgage with power of sale upon real property or any interest therein was given as security, following the exercise of the power of sale in such deed of trust or mortgage, the plaintiff shall set forth in his or her complaint the entire amount of the indebtedness which was secured by the deed of trust or mortgage at the time of sale, the amount for which the real property or interest therein was sold and the fair market value thereof at the date of sale and the date of that sale. Upon the application of either party made at least 10 days before the time of trial the court shall, and upon its own motion the court at any time may, appoint one of the probate referees provided for by law to appraise the property or the interest therein sold as of the time of sale. The referee shall file his or her appraisal with the clerk and that appraisal shall be admissible in evidence. The referee shall take and subscribe an oath to be attached to the appraisal that he or she has truly, honestly and impartially appraised the property to the best of his or her knowledge and ability. Any referee so appointed may be called and examined as a witness by any party or by the court itself. The court must fix the compensation of the referee in an amount as determined by the court to be reasonable, but those fees shall not exceed similar fees for similar services in the community where the services are rendered, which may be taxed and allowed in like manner as other costs. Before rendering any judgment the court shall find the fair market value of the real property, or interest therein sold, at the time of sale. The court may render judgment for not more than the amount by which the entire amount of the indebtedness due at the time of sale exceeded the fair market value of the real property or interest therein sold at the time of sale with interest thereon from the date of the sale; provided, however, that in no event shall the amount of the judgment, exclusive of interest after the date of sale, exceed the difference between the amount for which the property was sold and the entire amount of the indebtedness secured by the deed of trust or mortgage. Any such action must be brought within three months of the time of sale under the deed of trust or mortgage. No judgment shall be rendered in any such action until the real property or interest therein has first been sold pursuant to the terms of the deed of trust or mortgage, unless the real property or interest therein has become valueless.
Ca. Civ. Proc. Code § 580a