What event is this piece of code located in ? Without context we can't properly diagnose this. Can you post the full script ? If the variable pendingmatch is indeed a pending match then pendingMatch.getId(); will return an Id. If you are just using this in your script with no context to a pendingMatch then it will always fail.