The query below was working and I needed to modify it to only retrieve active accounts.
I added the addition portion of the StateCode check. (In Red below)
When this runs, it errors out stating that there is a syntax error. What did I do wrong?
function retrieveAccounts(accountNumberIdentifier, businessUnit)
{
var accountNumber = Xrm.Page.getAttribute(accountNumberIdentifier).getValue();
var businessUnitValue = GetBusinessUnitValue( businessUnit );
totalAccountCount = 0;
var serverUrl = getServerUrl();
var accountQueryUrl = getQueryString(accountNumber, businessUnitValue, serverUrl);
var retrievedAccounts = getODataRecords(accountQueryUrl);
totalAccountCount = retrievedAccounts.results.length;
}
function getQueryString(accountNumber, businessUnitValue, serverUrl)
{
var options = "$select=AccountNumber,fgs_BusinessUnit,CustomerTypeCode&"
+"$filter=AccountNumber eq '" + accountNumber
+ "' and fgs_BusinessUnit/Value eq " + businessUnitValue
+ " and CustomerTypeCode/Value eq " + CUSTOMER_VALUE
+ “ and StateCode eq 0”;
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var queryUrl = ODataPath + "/AccountSet?" + options;
return queryUrl;
}