Blog

Unprocessed Accounts

Report on Accounts without Contacts, Assets, Contracts, or Entitlements.

Script Include

Script Include: SNEReportUtil
Client Callable: true
Accessible from: All application scopes
Script:
var SNEReportUtil = Class.create();
SNEReportUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
	filterUnprocessedAccounts: function ()
	{
		var accounts = [];
		var grCA = new GlideRecord('customer_account');
		grCA.addEncodedQuery('customer=true');
		grCA.query();

		while(grCA.next()) {
			var contacts = getAccountCount('customer_contact', grCA.sys_id);
			var assets = getAccountCount('alm_asset', grCA.sys_id);
			var contracts = getAccountCount('ast_contract', grCA.sys_id);
			var entitlements = getAccountCount('service_entitlement', grCA.sys_id);
			if (contacts == 0 && entitlements == 0 && assets == 0) 
				
			
		}
		return accounts;

		function getAccountCount(table,sysID) {
			//Contact Count
			var ga = new GlideAggregate(table);	
			ga.addQuery('account',sysID);
			ga.addAggregate('COUNT');
			ga.query();
			if(ga.next()) {
				return ga.getAggregate('COUNT');
			}
		}
	},
	type: 'SNEReportUtil'
});

Report

Report: Unprocessed Accounts
Source Type: table
Table: Account [customer_account]
Filter: sys ID is one of javascript:new SNEReportUtil().filterUnprocessedAccounts();