The "cow-keeper"-story?
The following is somewhat like the posted question, but not exactly:

SN35.241:7.4: Sir, may I receive the going forth, the ordination in the Buddha’s presence?”


SN35.241:7.5: “Well then, Nanda, return the cows to their owners.”


SN35.241:7.6: “Sir, the cows will go back by themselves, since they love their calves.”


SN35.241:7.7: “Still, Nanda, you should return them to their owners.”

Here the Buddha emphasizes ethics in our relationships with others. The Noble Path starts with Right View.