Sempre que um usuário tenta executar uma análise, o Oracle Analytics chama a função validateAnalysisCriteria. Você pode personalizar validateAnalysisCriteria para validar e bloquear consultas com base em seus próprios critérios específicos. Se a função retornar true, a consulta será executada. Se a função retornar false ou exibir uma mensagem, a consulta será bloqueada.
Por exemplo, veja a seguir o código de amostra de um programa JavaScript chamado myblocking.js.
// This is a blocking function. It ensures that users select what
// the designer wants them to.
function validateAnalysisCriteria(analysisXml)
{
// Create the helper object
var tValidator = new CriteriaValidator(analysisXml);
// Validation Logic
if (tValidator.getSubjectArea() != "Sample Sales")
return "Try Sample Sales?";
if (!tValidator.dependentColumnExists("Markets","Region","Markets","District"))
{
// If validation script notifies user, then return false
alert("Region and District are well suited, do you think?");
return false;
}
if (!tValidator.dependentColumnExists("Sales Measures","","Periods","Year"))
return "You selected a measure so pick Year!";
if (!tValidator.filterExists("Sales Measures","Dollars"))
return "Maybe filter on Dollars?";
if (!tValidator.dependentFilterExists("Markets","Market","Markets"))
return "Since you are showing specific Markets, filter the markets.";
var n = tValidator.filterCount("Markets","Region");
if ((n <= 0) || (n > 3))
return "Select 3 or fewer specific Regions";
return true;
}
Se a função retornar qualquer informação diferente de false, os critérios serão considerados válidos e a análise será executada. A função também é usada para validar critérios das operações de visualização e salvamento.