Example to say : When Julia met Scott she hadn't realized he had been married before.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
It is not incorrect. However, she hadn't realized X is generally used to point out that up until some time or event, she had not (yet) realized X. For example, Until Julia met Scott's fourth ex-wife she hadn't realized that he had been married before.
Otherwise, if you just want to say that at the moment when she met him she did not know he had been married previously, then say that: When Julia met Scott she didn't realize he had been married before.
It's grammatically correct. "Before" might be redundant but even if it is it can merely intensify what you're saying, so it's correct.
Since you don't say what sense you want to convey, it's not possible to tell whether it says what you want. Some of the words have implications that aren't conclusive, but influence how the sentence would be understood.
In the particular part you ask about, saying "he had been married before" slightly suggests that either he is married now, or that Julia is thinking about Scott in terms of a future marriage. For example,
"When Julia met her friend's husband Scott, she learned he had been married before" -- that is to say, before marrying Julia's friend.
"When Julia met her future husband Scott, she learned he had been married before" -- that is to say, before marrying Julia.
"Julia didn't marry Scott because he had been married before" -- that is to say, before Julia and Scott's hypothetical marriage that she considered but that didn't occur.
It's not conclusive, because "married before" is also commonly used to talk about someone divorced or widowed, not just someone on a second marriage. But if you want to remove that suggestion, you could say "he had been married". This leaves things open to a construction like "he had been married for five years", which could mean he's still married at the time of the meeting and we're only talking about one marriage.
In the part you didn't ask about, "she hadn't realized" specifically means that prior to this meeting, Julia never realized it. If you want to emphasize that she never realized during their meeting, then you should say "she didn't realize". If you want to emphasise her state of knowledge rather than the event of realizing then you'd say "she hadn't known" or "she didn't know". In both cases, by saying "hadn't" rather than "didn't" you create a suggestion that during the meeting she did learn or realize. So at least you create a dramatic tension as to whether she will or not, if you go on to describe the meeting in more detail.