It was permitted to say Shalom to him to ask him something, but it would be better in the future if you say, “Good Morning.”
Brachot 14a: Rav said someone who greets his friend with Shalom before Shacharit is as if he made him into an altar, as it says Chadlu Lachem Min HaAdom…Ki BaMeh Nechshav…don’t read it Bameh rather Bamah. Shmuel said you honored him but not Hashem. Rav Sheshet contradicted this with a Mishna which says one may greet in between the paragraphs of Shema? R’ Abba explained Rav is discussing if he went specially to his house before Tefilla to greet him, that is forbidden.
What is the exact prohibition?
Rashi explains Shmuel does to understand the passuk like Rav rather it is giving a reason why it’s forbidden to greet him with Shalom first, since he did it before he spoke with Hashem. It would seem any greeting is forbidden before Shacharit.
The Talmidei Rabbeinu Yonah quote Rabbanei Provence that even fi you go to his house it sonly a problem if you say, “Shalom” since hashem’s name is also Shalom. It is permitted to greet him with , “Good Morning” since he does not say Shalom.
Rabbeinu Yonah himself said even Good Morning is a problem if he goes to his house however if he is looking into something or some to her business and he sees someone he may say Good Morning but not Shalom.
It would seem from Rabbeinu Yonah that if he was on the way to Bet Knesset and sees someone, he may even say Sholom since he’d go to his house.
His student the Rashba and the Ritva are both say that even if he meets him on the way to Bet Knesset, he may not greet him with Shalom, rather Good Morning. They derive this from the continuation of the Gemara that one may not go out to check on business before Tefilla, rather he must go straight to the Bet Knesset. The fore he may only say Good Morning to remind himself it is morning and he must go say Shacharit and not Shalom which will involve him in other things.
To summarize there are three opinions:
Rabbanei Provence who say you may go to his house and say Good morning.
Rabbeinu Yonah and Rashi who say you may to go to his house but if you meet hm on the way to the things you may say God Morning and if you are, he way to Bet Knesset you may say Shalom.
Rashba and the Ritva say on the way you may say Good Morning.
So rules the Shulchan Aruch (OH 89:2):One the time for Tefilla arrives it forbidden for someone to go early to his friend’s house and greet him Shalom, since Hashem’s name is Shalom but it’s permitted to say to him Good Morning .
Even if it is only permitted to greet him if he didn’t ‘specifically go to him but to check out something else but if he did then any greeting is forbidden… Some say that even if he saw in the market, he should only say Good Morning so you can get his attention and he’ll give you stuff in order to be quick t got Tefilla.
The Shulchan Aruch rules like Rabbeinu Yonah and the Rashba as ‘Some Say.’ It would seem he rules like the Rabbeinu Yonah when he is walking to do something else then he may say Good morning and even Shalom.
The Poskim disagree if he went specifically to his friend before Tefilla not to greet him since he has to deal with him before Tefilla. Can he say to him even Shalom or just Good Morning?
The Bach writes it sonly permitted to say to him Good Moring as long as he does not say Shalom and this is only permitted, he went to have some dealings with him. So, understands the Biur Halacha.
The Biur Halacha quotes the Pri Megadim who writes it is permitted to say Shalom even if he goes to his house to have some dealings it is only forbidden if he is on the way to his house to greet hi and he meets partway. The BH adds if he went to his place in the Bet Knesset to say Shalom it is also forbidden like gogn to hi house.
In our case He is not gogn to him to greet him rather he needs to h ask him something then it is an argument whether it is considered bum[ping into him which he might even say Shalom or like he went to his house and therefore he is only allowed to say Good Morning.
It seems one may be lenient and say Shalom as even the Yalkut Yosef writes that even though by meeting on the way one may say Shalom it is better to say Good Morning.
Therefore, it is better to say Good Morning but you may say Shalom.