Set value of a selection field depending if customer has any orders

SOLVED

I'm trying to set up a create script for a selection field ("quot_c_analysiscode2") on our quote summary screen to set the default value. The selection defines if they're a 'New Customer' or 'Existing Customer'. Rather than having users select it manually, I want it to be set as 'Existing Customer' by default if they have any existing orders, otherwise set to 'New Customer'. 

I put this script together that I thought would work, but it doesn't. Can anyone advise what needs to change to get this working?

var selectedValue = CRM.GetContextInfo("quote","quot_c_analysiscode2");

if (!selectedValue || selectedValue === "null" || selectedValue === "") {

	var OppoId = CRM.GetContextInfo("opportunity","oppo_opportunityid"); 
	 
	if (!isNaN(parseInt(OppoId, 10)) && parseInt(OppoId, 10) > 0) //confirm result is valid
	{
		var CompanyId = CRM.CreateQueryObj("SELECT comp_companyid FROM vOpportunity WHERE oppo_opportunityid = " + OppoId);
	 
		CompanyId.SelectSql();
	 
		if (!CompanyId.Eof) //valid result returned
		{
			var OrderCount = CRM.CreateQueryObj("SELECT COUNT(Orde_OrderQuoteID) AS OrderCount FROM vSummaryOrder WHERE Comp_CompanyId = " + CompanyId.FieldValue("comp_companyid"));
			OrderCount.SelectSql();
			
			if (!OrderCount.Eof){ //valid result returned
				if (parseInt(OrderCount.FieldValue("OrderCount"), 10) > 0){
					DefaultValue = 'EC';
				} else{
					DefaultValue = 'NC';
				}
			}
		}
	}
}