Hi Ning,
In this case, both of these could be used.
In advance is usually used to say that something has to be done days or hours before.
Beforehand is usually used to say that something has to be done before something starts.
I ordered the tickets to the concert in advance to make sure they wouldn't sell out.
We will go to the meeting soon, i just have to go to the toilet beforehand.
They are often interchangeable, but definitely not always.
For example;
You would say: Thank you in advance
You wouldn't say: Thank you beforehand.
You would say: I just have to go to the toilet beforehand.
You wouldn't say: I just have to go to the toilet in advance.
The difference is subtle, but it is there.
Hope this helps.
Pascale