I read the story in the introduction to a compilation sefer of the Noda Biyehuda's commentary on Tanakh. The Besh"t was eating in the Noda Biyehuda's house when the maid entered to ask a question on something cooked in the kitchen. The NB thought and said it was kosher. The Besht said he could tell it was kosher because there was no tumah on the food. The NB responded that with that attitude people would stop learning Torah. I forget the Besht's response, but I think it was a proof from history.
UPDATE (I remembered the response): The Besh"t answered with a gemara in Shabbos
תָּנוּ רַבָּנַן: כְּשֶׁנִּכְנְסוּ רַבּוֹתֵינוּ לַכֶּרֶם בְּיַבְנֶה אָמְרוּ, עֲתִידָה תּוֹרָה שֶׁתִּשְׁתַּכַּח מִיִּשְׂרָאֵל, שֶׁנֶּאֱמַר: ״הִנֵּה יָמִים בָּאִים נְאֻם ה׳ אֱלֹהִים וְהִשְׁלַחְתִּי רָעָב בָּאָרֶץ לֹא רָעָב לַלֶּחֶם וְלֹא צָמָא לַמַּיִם כִּי אִם לִשְׁמוֹעַ אֵת דִּבְרֵי ה׳״, וּכְתִיב: ״וְנָעוּ מִיָּם עַד יָם וּמִצָּפוֹן וְעַד מִזְרָח יְשׁוֹטְטוּ לְבַקֵּשׁ אֶת דְּבַר ה׳ וְלֹא יִמְצָאוּ״. יא״דְּבַר ה׳״ — זוֹ הֲלָכָה, ״דְּבַר ה׳״ — זֶה הַקֵּץ, ״דְּבַר ה׳״ — זוֹ נְבוּאָה. יבוּמַאי ״יְשׁוֹטְטוּ לְבַקֵּשׁ אֶת דְּבַר ה׳״? אָמְרוּ: עֲתִידָה אִשָּׁה שֶׁתִּטּוֹל כִּכָּר שֶׁל תְּרוּמָה וְתַחֲזוֹר בְּבָתֵּי כְנֵסִיּוֹת וּבְבָתֵּי מִדְרָשׁוֹת לֵידַע אִם טְמֵאָה הִיא וְאִם טְהוֹרָה הִיא, וְאֵין מֵבִין
When our Sages entered the vineyard in Yavne, they said: The Torah is destined to be forgotten from the Jewish people, as it is stated: “Behold, days are approaching, says the Lord God, and I will send forth a hunger in the land, not a hunger for bread and not a thirst for water, but for hearing the words of the Lord” (Amos 8:11). And it states: “And they will drift from sea to sea, and from north to east they will roam to find the word of the Lord, but they will not find it” (Amos 8:12). 11“The word of the Lord” in this context bears many meanings. “The word of the Lord”; that is halakha. “The word of the Lord”; that is the end of days. “The word of the Lord”; that is prophecy. All these will be lost from the Jewish people. 12And what is the meaning of: “They will roam to find the word of the Lord, but they will not find it”? They said: It is destined that a woman will take a loaf of teruma bread and circulate among the synagogues and study halls to ascertain whether it is ritually impure or whether it is ritually pure, and there will be none who understands.
The Besh"t asked, "Why does this woman need to bring the loaf to the synagogue? Let her leave it at home and describe the question? Because if there is nobody who can answer the question using a source from halacha, maybe someone can look at the loaf and see if it is impure."