In 2 Chronicles, there are two interesting events that take place at the temple and interweave across time.
First is the account of the dedication of the temple. The temple was built around 900 BC by King Solomon. The day of the temple's dedication was one of much praise and worship and festivity. The ark of the covenant was brought inside the temple and set in the holiest place. The people were standing assembled before the area as sacrifices of sheep and oxen were made. The priests blew trumpets and the Levites sang praises to God and played cymbals, harps, and lyres. They sang with one voice, "He indeed is good for His lovingkindness is everlasting." Then, the glory of the LORD filled the house in the form of a cloud. King Solomon blessed the people and then, kneeling on his knees and spreading out his hands toward heaven, he prayed to the LORD. In his prayer, he said:
"If there is famine in the land, if there is pestilence, if there is blight or mildew, if there is locust or grasshopper, if their enemies besiege them in the land of their cities, whatever plague or whatever sickness there is, whatever prayer or supplication is made by any man or by all Your people Israel, each knowing his own affliction and his own pain, and spreading his hands toward this house, then hear from heaven Your dwelling place, and forgive, and render to each according to all his ways, whose heart You know for You alone know the hearts of the sons of men, that they may fear You, to walk in Your ways as long as they live in the land which You have given to our fathers."
After the prayer, many sacrifices were offered, the Levites again sang praise to God, and a feast was held for seven days. Thus the temple was dedicated.
Fast-forward four generations, about a century later. During the intervening time, the kingdom of Israel had split into two parts - the Southern Kingdom and Northern Kingdom. Jerusalem, the city of the temple, is the center of the Southern Kingdom. It is also called the Kingdom of Judah. King Solomon's great-grandson is ruling as king there. His name is Jehoshaphat.
In the days of Jehoshaphat, a foreign army rises and comes up against him to fight. King Jehoshaphat is afraid, and he looks to the LORD for deliverance. He proclaims a fast throughout his land, and the people gather at the temple along with the king to seek help from the LORD. King Jehoshaphat prays and quotes his great-grandfather's prayer, which was made at the dedication of the same temple where he is now standing:
"They...have built You a sanctuary there for Your name, saying, 'Should evil come upon us, the sword, or judgment, or pestilence, or famine, we will stand before this house and before You (for Your name is in this house) and cry to You in our distress, and You will hear and deliver us.'" In his prayer, the king admits that they are powerless and do not know what to do, but that they look to God.
In response, God sends His Spirit upon one of the Levites, Jahaziel. God speaks through this man and tells the king and the people not to fear, but to go down against this army the next day. He tells them where the enemy will be and gives them instructions to station themselves and to stand and see the salvation of the LORD. He commands them again not to fear, but to go out the next day, and tells them that He will be with them. When the people hear these words from God, King Jehoshaphat bows his head and face to the ground and the people fall down and worship God. The Levites stand up to praise God.
The next day, they leave early to go against the enemy. As they take their place, King Jehoshaphat commands the people to believe God and appoints the singers to sing. They lift up their voices saying, "Give thanks to the LORD, for His lovingkindness is everlasting." And God gives them the victory.
"His lovingkindness is everlasting"
2 Chronicles chapters 5, 6, 7, 20