This. Plus you can check GetInstanceInfo.
http://wowprogramming.com/docs/api/GetInstanceInfo
Lua Code:
local checkStatus = function()
local name, type, difficulty, difficultyName, maxPlayers, playerDifficulty, isDynamicInstance = GetInstanceInfo()
if type = "party" and GetNumGroupMembers() > 0 and not UnitInRaid("player") then
print("I'm in a party")
end
end
local a = CreateFrame("Frame")
a:SetScript("OnEvent", checkStatus)
a:RegisterEvent("PLAYER_ENTERING_WORLD")
a:RegisterEvent("PARTY_MEMBERS_CHANGED")