ADVANCED SEARCH
JSON Format

 

You can post a advanced search request directly using a JSON formatted criteria object to the /rpc/... endpoint.

You can pass your criteria using JSON. If posting (the recommended method) the criteria can either be the data, or be posted as criteria=.

If doing a GET, the criteria should be passed via criteria= - make sure it is encoded, eg. encodeURIComponent(sCriteria), and under ~1600 characters.

If you are posting using a agent that does not provide cookie support, then add &logonkey= and &sid= to the data.

  Example of Javascript to POST the criteria
 
$.ajax({
	type: 'POST',
	url: '/rpc/financial/?method=FINANCIAL_INVOICE_SEARCH';,
	data: 'criteria=...',
	success: function(asData) { 
			SearchComplete(asData)
		},		
	dataType: 'json'
});
  JSON
 
{
	"fields":
	[
		{
			"name": "..."
		}
	],
	"summaryFields":
	[
		{
			"name": "..."
		}
	],
	"filters":
	[
		{
			"name": "...",
			"comparison": "...",
			"value1": "...",
			"value2": "...",
			"value3": "..."
		}
	],
	"sorts":
	[
		{
			"name": "...",
			"direction": "..."
		}
	],
	"options":
	{
		"rf": "...",
		"startrow": "...",
		"rows": "...",
		"returnparameters": "..."
	},
	"customoptions":
	[
		{
			"name": "...",
			"value": "..."
		}
	]
}
  EXAMPLES
   
 1. Using JSON, return the sentdate, and the count, of all sent invoices, ordering by their reference. Return the data in JSON format. You would post this to FINANCIAL / FINANCIAL_INVOICE_SEARCH
 
{
	"fields":
	[
		{
			"name": "sentDate"
		}
	],
	"summaryFields":
	[
		{
			"name": "count(*) invoicecount"
		}
	],
	"filters":
	[
		{
			"name": "sent",
			"comparison": "EQUAL_TO",
			"value1": "N",
			"value2": ""
		}
	],
	"sorts":
	[
		{
			"name": "reference",
			"direction": "asc"
		}
	],
	"options":
	{
		"rf": "JSON"
	}
}
 2. Sample Javascript to generate the above JSON
 
function Go() {
	var sURL = '/rpc/financial/?method=FINANCIAL_INVOICE_SEARCH';
	var sData = '';
	var oSearch = {};
	
	oSearch.fields = [];
	oSearch.fields.push({});
	oSearch.fields[0]['name'] = 'sentdate';
	
	oSearch.summaryFields = [];
	oSearch.summaryFields.push({});
	oSearch.summaryFields[0]['name'] = 'count(*) invoicecount';
	
	oSearch.filters = [];
	oSearch.filters.push({});
	oSearch.filters[0]['name'] = 'sent';
	oSearch.filters[0]['comparison'] = 'EQUAL_TO';
	oSearch.filters[0]['value1'] = 'N';
	
	oSearch.sorts = [];
	oSearch.sorts.push({});
	oSearch.sorts[0]['name'] = 'reference';
	oSearch.sorts[0]['direction'] = 'asc';
	
	oSearch.options = {};
	oSearch.options.rf = 'JSON';
	
	sData = JSON.stringify(oSearch);
	
	$.ajax({
		type: 'POST',
		url: sURL,
		data: 'criteria=' + sData,
		success: function(asData) { 
				SearchComplete(asData)
			},		
		dataType: 'JSON'
	});
}
3. ajax call
  $.ajax({url:'', type: 'POST', data: 'criteria={fields: [{name: ""}], filters: [{name: "", comparison: "EQUAL_TO", value1: "", value2: ""}]}'});
Help!