Adding additional fields to the case search screen
Some people have asked how to show additional fields in the case search screen. Until recently, this hasnt been possible, but the October update now allows you to access this data using the custom JavaScript feature.
To show extra question values, use this:
jQuery(function ($) {
alreadyHaveAnswerFlag = 'has_answer';
onAfterPolicySearch = getAnswerValues;
function getAnswerValues() {
var questionNames = ['QuestionNameOne', 'QuestionNameTwo'];
var policyRecordIds = [];
$('.policy_link').each(function (i, el) {
if (!$(el).hasClass(alreadyHaveAnswerFlag)) {
policyRecordIds.push(el.id);
}
});
$.post("AjaxHandlers/GetAnswerValues.ashx", { "PolicyRecordIds[]": policyRecordIds, "QuestionNames[]": questionNames }, addAnswersToSearchResults);
}
function addAnswersToSearchResults(results) {
var format = '<h5 class="client_link"><b>#QuestionName#: </b> #AnswerValue#</h5>';
$(results).each(function (i, result) {
$('#' + result.PolicyRecordId)
.addClass(alreadyHaveAnswerFlag)
.siblings('.broker_client').append(result.AnswerValue ? format.replace('#QuestionName#', result.QuestionName).replace('#AnswerValue#', result.AnswerValue) : null);
});
}
});
Please sign in to leave a comment.
Comments
0 comments