Hi,
I’m trying to follow the example here: spchart.com/demo/helpdesk-dashboard/config
but instead of filtering my charts by users (agents) i’m trying to use CSL field on my list with an internal name “KeyPrincipal”, however the drop down list is not populating, below is the code i’m using, appreciate your help.
[code]var handlers = {};
handlers.requestInit = function (query, logger) {
var view = query.get_viewXml();
var accountId = $('#key-principals').val();
if (accountId && accountId !== '0') {
view = view.replace('{Filter}', '<And>\
<Eq>\
<FieldRef Name ="KeyPrincipal" />\
<Value Type="Lookup">' + accountId + '</Value>\
</Eq>\
<Neq>\
<FieldRef Name="RecordType" />\
<Value Type="Choice">Variant</Value>\
</Neq>\
</And>');
} else {
view = view.replace('{Filter}', '<Neq>\
<FieldRef Name="RecordType" />\
<Value Type="Choice">Variant</Value>\
</Neq>');
}
logger.info(view);
query.set_viewXml(view);
return true;
}
handlers.requestSuccess = function (data, logger) {
populateKeyPrincipals(data);
return true;
}
handlers.aggregationSuccess = function (data, logger) {
return true;
}
handlers.finish = function (data, logger, processor, el) {
logger.debug('Data is processed: ', data);
if (processor && !processor.subscribed) {
$('#key-principals').change(function () {
el.empty().html('<img alt="loading..." src="/_layouts/15/images/gears_anv4.gif" />');
processor.process(el);
});
processor.subscribed = true;
}
return true;
}
function populateKeyPrincipals(data) {
if ($(’#key-principals option’).length == 1) {
var principals = {};
$.each(data.items, function () {
if (!principals[this.KeyPrincipalId]) {
principals[this.KeyPrincipalId] = this.KeyPrincipal;
}
});
for (var key in principals) {
$('#key-principals').append($('<option></option>')
.attr('value', key)
.text(principals[key]));
}
}
}[/code]