¶ 1 Donna Kelly appeals from the January 26, 2005 Order sustaining appellee/ex-husband’s preliminary objections in the nature of a demurrer and dismissing her complaint in assumpsit with prejudice.
¶ 2 The parties were divorced by Decree dated September 8, 1999. According to the trial court, litigation has continued since and centers upon appellant’s claim to a share of appellee’s railroad retirement “Tier 2” benefits. In the instant action, appellant alleges that the parties’ had entered into an agreement pursuant to which appellee agreed to provide appellant with half of his railroad retirement benefits. Record No. 3, Amended complaint. Appellant complains that since November 2002 appellee has received railroad retirement benefits, but she did not receive any portion of payments made to him from November 2002 until May 2003. Accordingly, she claims appellee has been unjustly enriched. Id.
¶ 3 Appellee filed preliminary objections to the complaint based upon res judicata. Record No. 7. As noted above, the court sustained the objections by its January 26, 2005 Order. Record No. 8. In that Order, the court indicated that the issues appellant raised in the complaint, regardless of how they were framed, were precisely the same as those of which it had disposed in its March 19, 2003 Order. Id.; see also Record No. 7, Exhibit “A”, Trial Court Order, 3/19/03.
¶4 The court’s March 19, 2003 Order was entered in the context of the divorce *790action, in response to a pleading filed by appellant, entitled “petition to enforce marriage settlement agreement,” in which she apparently sought a share of appellee’s Tier 2 railroad benefits. See Record No. 7, Exhibit “A”, Trial Court Order, 3/19/03. In that Order, the court noted that appel-lee does not dispute that appellant is entitled to a share of his Tier 2 railroad retirement benefits. It directed appellant that in order to receive the benefits, she must file a Qualified Domestic Relations Order (QDRO) with the Railroad Retirement Board, but she failed to do so. If she had filed, the court explained, payment of benefits to appellant would have begun contemporaneously with appellee’s February 2002 retirement. The court found without merit appellant’s assertion that appellee was obligated to pay her from his own monies the amount she would have received from Tier 2. The court faulted appellant and her counsel for the failure to file the required QDRO, denied the petition and dismissed it with prejudice. Id.
¶ 5 In an April 27, 2005 Opinion, the court elaborated on its January 26, 2005 Order. According to the trial court, appellant filed the instant action after her property distribution claims were adjudicated to finality in the divorce action, and, during the litigation of that action, the court considered and dismissed appellant’s claims to the Tier 2 benefits. Trial Court Opinion, 4/27/05, Peoples, J., at 2. It also reiterated the holdings of its March 19, 2003 Order. The court concluded by stating that appellant failed to proceed via a QDRO in connection with the divorce action, and took no appeal from the final Order in that matter regarding Tier 2 benefits. The court found she was not entitled to have the March 19, 2003 Order overruled in this collateral proceeding and is foreclosed from any further pursuit of those monies. Id.
¶ 6 Appellant filed this timely appeal in which she raises the following issues for our review:
Whether the court erred in granting defendant’s preliminary objections when the facts relied upon to establish res judicata are not established in the complaint itself?
Whether the court erred in barring the cause of action of unjust enrichment when it was not determined whether the defendant was unjustly enriched by receiving his full pension for over a year, knowing his wife was ordered a percentage of it?
Whether there exists any other remedy at law for the plaintiff other than the equitable relief requested?
Appellant’s brief at in. We address these issues seriatim.
¶ 7 In addressing appellant’s first issue on appeal, we begin by noting that preliminary objections are limited to the grounds enumerated in Pa.R.Civ.P. 1028, Preliminary Objections. Appellee indicated res judicata as the basis for his preliminary objection. Record No. 7. Res judicata is not among those grounds enumerated in Rule 1028(a). The issue of res judicata, rather, is an affirmative defense and generally is properly raised via a party’s answer as new matter. Pa.R.Civ.P. 1030, New Matter (a).
¶ 8 “A preliminary objection in the nature of a demurrer tests the legal sufficiency of the' complaint.” Constantino v. University of Pittsburgh, 766 A.2d 1265, 1268 (Pa.Super.2001). “A court should sustain preliminary objections in the nature of a demurrer only where it appears from the face of the complaint that recovery upon the facts alleged is not permitted as a matter of law.” 220 Partnership v. Philadelphia Elec. Co., 437 Pa.Super. 650, 650 A.2d 1094, 1096 (1994). “When consid*791ering a demurrer[,] a court cannot consider matters collateral to the complaint but must limit itself to such matters as appear thereinId. “A court may not ordinarily take judicial notice in one case of the records of another case, whether in another court or its own, even though the contents of those records may be known to the court.” Id., at 1097 (citations omitted). It follows, therefore, that unless the facts relied upon to establish it appear from the complaint itself, the defense of res judicata, may not be raised by preliminary objections. Cf. Id. (Stating that it follows that the doctrine of collateral estoppel may not be raised by preliminary objections); see also Chada v. Chada, 756 A.2d 89, 42-43 (Pa.Super.2000) (stating that the doctrine of res judicata “subsumes” the modern doctrine of collateral estoppel).
¶9 Appellee maintains that appellant’s complaint references and incorporates by reference her petition in the prior action. Appellee’s brief at 4. If this were true, it would be appropriate for the court to take notice of it. See Id. Our review of the record reveals, however, that while the complaint references the marriage settlement agreement, it does not reference the prior action.
¶ 10 In this very limited circumstance, however, we find the court’s action in considering the defense of res judicata (or collateral estoppel) raised in the context of a preliminary objection, was not improper.
¶ 11 First, we note that there are no facts in dispute here. As noted in 220 Partnership, judicial notice “should not be used to deprive an adverse party of the opportunity to disprove a fact.” Id., at 1096 (emphasis supplied). Further, a court reviewing preliminary objections should not take judicial notice of collateral facts. Id., at 1097. In 220 Partnership, the appellant partnership filed an action against appellee electric utility and its agent arguing tortious interference with appellant’s relationship with tenants of its building. The appellees filed a demurrer alleging that appellant did not own the building because its interest had been sold at a bankruptcy sale. The trial court took judicial notice of the federal bankruptcy proceedings and dismissed appellant’s complaint. Upon review, this Court reversed and remanded. We found it was improper for the trial court, at the demurrer stage, to take judicial notice of proceedings in another court and thereby deny the appellant of the opportunity to prove a material fact, in that case, appellant’s interest in the building. See id. In this case, however, as stated previously, there are no facts in dispute.
¶ 12 Also, in Dempsey v. Cessna Aircraft Co., 439 Pa.Super. 172, 653 A.2d 679, 680 (1995) (en banc), this Court considered a matter in which, in response to preliminary objections, the trial court dismissed the action on the grounds of res judicata. Although we recognized that res judicata is an affirmative defense and should be pleaded as new matter in an answer, we did not reverse on that basis because the facts were not in dispute and because neither party objected to the procedure. Id. Ultimately, in fact, we affirmed the trial court. Id. Here, in contrast, appellant in her first issue effectively objects to this procedural irregularity. See appellant’s brief at 3-4. Although we acknowledge with displeasure that proper procedure was not followed in this case, we will not reverse on this basis. As in Dempsey, the facts in this case are not in dispute, and thus, appellant was not deprived of an opportunity to prove or disprove a fact. In ruling on the preliminary objections, moreover, the court did not take notice of any collateral facts. We conclude this case is very straightforward and as a matter of judicial economy and efficiency, we will not *792reverse based upon this procedural abnormality.
¶ 13 Underlying the doctrine of res judicata is the principle that:
Where parties have been afforded an opportunity to litigate a claim before a court of competent jurisdiction, and where the court has finally decided the controversy, the interests of the state and of the parties require that the validity of the claim and any issue actually litigated in the action not be litigated again.
Dempsey, supra, at 681 (citation omitted).
¶ 14 “Application of the doctrine of res judicata requires that the two actions possess the following common elements: (1) identity of the thing sued upon; (2) identity of the cause of action; (3) identity of the parties; (4) identity of the capacity of the parties.” Id.
¶ 15 Applying the above, it is clear that the only element in dispute is the second, i.e., the identity of the cause of action. Appellant disputes that the causes of action are the same. She argues that a quasi-contractual action of unjust enrichment is separate from a petition to enforce a marriage settlement agreement. Appellant’s brief at 2. The Dempsey Court explained:
A fundamental test applied for comparing causes of action, for the purpose of applying principles of res judicata, is whether the primary right and duty, and delict or wrong, are the same in each action. Under this test, there is but one cause of action where there is but one right in the plaintiff and one wrong on the part of the defendant involving that right.
Dempsey, at 681 (citation omitted, emphasis supplied).
Identity of two causes of action may be determined by considering the similarity in the acts complained of and the demand for recovery as well as the identity of the witnesses, documents and facts alleged. In determining whether res judicata should apply, a court may consider whether the factual allegations of both actions are the same, whether the same evidence is necessary to prove each action and whether both actions seek compensation for the same damages.
Id. (Citations omitted, emphasis supplied).
¶ 16 Applying the above, it is clear that res judicata applies here. Appellant quite clearly is seeking to enforce the same right, her right to a portion of appellant’s Tier 2 railroad retirement benefits, and the same alleged wrong in appellee, his receipt of these benefits without giving appellant a share. Appellant is unmistakably complaining of the same acts, makes the same demand for recovery, and is seeking compensation for the same damages. It is irrelevant that appellant first brought the claim as a petition to enforce the marriage settlement agreement in the context of a divorce action, and now as a claim of unjust enrichment:
The application of the doctrine of res judicata to identical causes of action does not depend upon the identity or differences in the forms of the two actions. A judgment upon the merits bars a subsequent suit upon the same cause, though brought in a different form of action, and a party therefore cannot, by varying the form of action or adopting a different method of presenting his case, escape the operation of the principle that one and the same cause of action shall not be twice litigated.
Id., at 682 (citation omitted, emphasis supplied).
*793¶ 17 For the above stated reasons, we affirm the January 26,2005 Order.
¶ 18 Order affirmed.