
395 N.W.2d 850 (1986)
LOWERY INVESTMENTS CORP. and Richard Lowery, Appellants,
v.
STEPHENS INDUSTRIES, INC., Appellee.
No. 85-438.
Supreme Court of Iowa.
November 12, 1986.
Robert A. Wright, Sr. of Wright, Wright & Borseth, Des Moines, and Dennis L. Eaton, Des Moines, for appellants.
William J. Lillis and Peter S. Cannon of Connolly, O'Malley, Lillis, Hansen & Olson, Des Moines, for appellee.
Considered by REYNOLDSON, C.J., and HARRIS, LARSON, SCHULTZ, and CARTER, JJ.
CARTER, Justice.
Plaintiffs appeal from a judgment for the defendant, Stephens Industries, Inc. (vendor corporation), in an action seeking to set aside the forfeiture of the vendee's interest under a contract for the sale of commercial real estate. The district court heard the case in equity and determined that the plaintiffs had failed to establish any basis for avoiding the forfeiture in accordance with the terms of the agreement. Because we find that the substantive claims presented in the present action have been resolved adversely to the plaintiffs by a prior judgment in an action for forcible entry and detainer of the subject property, we uphold the judgment of the district court on grounds of claim preclusion.
In 1978, the vendor corporation's assignors sold certain commercial real estate on contract to Lowery Investments Corp. *851 (vendee corporation). The purchase price for the property was $75,000. A down payment of $12,000 was required with subsequent monthly payments of $587.48. The contract provided the vendors with a remedy of forfeiture on default of payment in accordance with Iowa Code chapter 656. The vendors' interest in the contract was subsequently assigned to the vendor corporation.
Richard Lowery (Lowery) was sole officer and shareholder of the vendee corporation. At least three notices of forfeiture were served on the vendee corporation prior to January 1984. The contract continued in force, however, as the parties worked out the delinquencies giving rise to these notices. Another notice of forfeiture was served in January 1984. Lowery contacted the lawyer for the vendor corporation, and an agreement was reached for forbearance in completing the proposed forfeiture if the vendee corporation made up delinquent payments and provided proof of insurance.
Four delinquent monthly payments were made in accordance with this agreement. Additional delinquent payments were not forthcoming, however, because, according to Lowery, he was required to expend all additional money available to the vendee corporation for repairs to the property. A copy of the January 1984 notice of forfeiture is not included in the record. Lowery concedes, however, that, after four delinquent payments had been made, this only cured defaults in monthly payments through November of 1983. The remaining principal balance of the contract at this time was $55,209. The December 1983 payment included in the January 1984 notice of forfeiture was not paid. In addition, the vendee corporation failed to make the monthly payments which accrued under the contract subsequent to service of that notice.
On May 15, 1984, the vendee corporation was served with yet another notice of forfeiture which is the subject of the present litigation. The notice specified various grounds for default, including nonpayment of taxes and utility bills, failure to meet the monthly payments due under the contract, and failure to properly insure the premises. In June 1984, Lowery tendered, on behalf of the vendee corporation, somewhat less than the amounts specified in the May notice of forfeiture. This offer was refused by the vendor corporation's attorney. On June 18, 1984, the forfeiture was completed pursuant to Iowa Code chapter 656 by recordation of the May 15, 1984 notice and appropriate affidavits of noncompliance.
On July 18, 1984, the vendee corporation brought an action in equity seeking a declaratory judgment and equitable decree avoiding the legal consequences of the forfeiture. The stated grounds for relief were: (1) that the notice of forfeiture was not served on Lowery, individually, as the party in possession of the subject premises; (2) that forfeiture of the contract by the vendor corporation was in violation of an oral agreement granting plaintiffs an extension of time for curing the default; (3) that the inclusion of delinquent utility bills as a ground of forfeiture was improper because the contract did not require the vendee corporation to assume those obligations; and (4) that, contrary to the claim of the vendor corporation, the vendee corporation had obtained a binder for insurance on the property. The vendor corporation answered denying the material allegations of the petition. Prior to trial, it amended its answer to raise an affirmative defense of claim preclusion based on a favorable judgment received in an action for forcible entry and detainer of the subject property. After trial of the present action, the district court found and concluded that the vendee corporation had failed to establish any of the asserted grounds for relief from the forfeiture. It did not consider the affirmative defense of issue preclusion raised by the vendor corporation.
At or about the same time the vendee corporation's action in equity was commenced, the vendor corporation commenced an action for forcible entry and detainer of the subject property. It prayed in this action that the court grant it possession of *852 the premises as against the vendee corporation. The petition alleged that the forfeiture of the vendee corporation's interest had been completed pursuant to Iowa Code chapter 656 on June 18, 1984, and that, as a result, the vendor corporation was entitled to immediate possession of the premises.
An order fixing time and place of hearing on the merits of the forcible entry action was served on the vendee corporation. The vendee corporation and Lowery appeared in court with an attorney on the date specified in that order. At this time, the parties entered into a stipulation involving the subject matter of the present action. This stipulation recognized the pendency of the present action seeking to avoid the legal consequences of the forfeiture. It provided that further proceedings in the forcible entry action would be held in abeyance conditioned upon payment of certain sums by the vendee corporation within a prescribed time. Specifically, it provided that, on or before August 1, 1984, the vendee corporation was to pay the delinquent contract payments for the period of December 1983 through August 1984, totaling $5287.32.
The agreement provided that, if such payments were made and the vendee corporation was unsuccessful in the action seeking to avoid the forfeiture, the payments would be the property of the vendor corporation in lieu of rentals for the vendee corporation's possession of the property during the pendency of the action. The agreement also provided that, if the vendee corporation should be successful in its efforts to avoid the forfeiture, the $5287.32 would be considered to have been payments under the contract which would otherwise continue in force according to its terms. It was further provided in the stipulation that, if the sum of $5287.32 was not paid to the vendor corporation on or before August 1, 1984, the vendee corporation "shall thereby waive, release and discharge any right, claim, or entitlement it may have to challenge or dispute the validity of the forfeiture of the contract and the Plaintiff [vendor corporation] shall then be entitled to a writ of possession for the property in question."
When the vendee corporation failed to make the required payments on or before August 1, 1984, another hearing was held in the forcible entry and detainer action. At this hearing the vendor corporation offered the stipulation of the parties and established the failure of the vendee corporation to make the required payments. It requested judgment pursuant to the stipulation. The court hearing the forcible entry action granted that request, and a judgment was entered in that action placing the vendor corporation in possession of the subject premises. This judgment formed the basis for the affirmative defense of claim preclusion raised by the vendor corporation in its amended answer in the equity action.
We are committed to the view that a defendant who prevails at trial on the infirmity of plaintiff's allegations may, without cross appealing, seek affirmance of the judgment on appeal based on the validity of affirmative defenses not considered by the trial court. See Kroblin Refrigerated X Press Inc. v. Ledvina, 256 Iowa 229, 233, 127 N.W.2d 133, 136 (1964); McCuddin v. Dickinson, 230 Iowa 1141, 1143, 300 N.W. 308, 309 (1941). In the present case, the vendor corporation pleaded and proved the judgment in the forcible entry action as evidence of claim preclusion. We hold it is entitled to prevail on that theory. This conclusion makes it unnecessary to consider the merits of the propositions which it argues on appeal.
We have recognized that claim preclusion, as a component of the doctrine of res judicata, is based on the principle that a party should not be permitted to split or try a claim piecemeal, but must put in issue and try the entire claim or put forth the entire defense in the first action which proceeds to final judgment. B & B Asphalt Co. v. T.S. McShane Co., 242 N.W.2d 279, 286 (Iowa 1976). A valid and final judgment in an action brought to establish rights or legal relations is conclusive in a subsequent action between the same parties *853 based upon the same claim. Fournier v. Illinois Casualty Co., 391 N.W.2d 258, 260 (Iowa 1986); B & B Asphalt Co., 242 N.W.2d at 286.
In Fournier, 391 N.W.2d at 260, we approved the test set forth in Restatement (Second) of Judgments for determination of the dimensions of a claim that has previously been litigated. The Restatement's suggested test is as follows:
(1) When a valid and final judgment rendered in an action extinguishes the plaintiff's claim pursuant to the rules of merger or bar ..., the claim extinguished includes all rights of the plaintiff to remedies against the defendant with respect to all or any part of the transaction, or series of connected transactions, out of which the action arose.
(2) What factual grouping constitutes a "transaction," and what groupings constitute a "series," are to be determined pragmatically, giving weight to such considerations as whether the facts are related in time, space, origin, or motivation, whether they form a convenient trial unit, and whether their treatment as a unit conforms to the parties' expectations or business understanding or usage.
Restatement (Second) of Judgments § 24 (1980) (emphasis added).
Application of the foregoing standards to the present dispute convinces us that the validity of the vendor corporation's action in forfeiting the interest of the vendee corporation under the contract was necessarily resolved adversely to the vendee corporation in the forcible entry action. The allegations of the petition in the forcible entry action make it clear that the vendor corporation's asserted right of possession was dependent upon the validity of the forefeiture under Iowa Code chapter 656. Accordingly, the present claim is barred by a traditional application of the claim preclusion doctrine without regard to the issue of contractual estoppel arising from the stipulation entered into in the forcible entry litigation.
We have considered all claims presented and determine that the judgment of the district court should not be disturbed.
AFFIRMED.
