Hi Paul.
Sorry for the delay, i have been out of the office for a few days.
Here you go http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipsdk/html/ipsdkIntroducingInfoPathDevelopment_HV01073333.asp
thisXDocument is not the object in script. Use XDocument;
GMSRef = ...