Hi Jim, In C# when you're accessing a collection, you need to make sure there's an item in the collection before you get it: If MyReturnedRecords has 5 items and you try to get the tenth one like MyReturnedRecords[9], you'll get an error. This is what's happening when you try to get the first result when there are none. You can check the size of the Entities property before you access it to make sure it's the right size: EntityCollection MyReturnedRecords = service.RetrieveMultiple(query); string returnValue = "No records exist"; if (MyReturnedRecords.Entities.Count > 0 && MyReturnedRecords.Entities[0].Contains("new_licenseinfoid")) { returnValue = MyReturnedRecords[0]["new_licenseinfoid"].ToString(); } return returnValue; Note: I'm at home so the properties are from memory so the spelling may be off. In this code, it's checking the Entities collection Count (or Length) to make sure there's at least one record, and it has the new_licenseinfoid property before it tries to get it. This way, it'll only get the first item if it exists, and only get the property if it exists. Hope this helps! Let me know if I explained something poorly and I'd be happy to try and clarify. If this helps I'd appreciate if you'd mark this as a Verified answer. Thanks, Aiden
↧