0 votes


in most projects the customers needs some queryviews to be by "default".
so there is a solution I ve done to help them having control about it :

in the workflow add the code :

function AfterLogon(){

function initUserOptions(){
    //Database.Log("Ok then");

        qh = 0,
        tc = Database.OpenTemporaryContext(),
        sql = "";

    sql += "select ";
    sql += "    V.K_QUERYVIEW, ";
    sql += "    (select E.NAME from admin.SYS_ENTITIES E where E.K_ENTITY = V.K_MASTER) as MASTER_NAME, ";
    sql += "    (select E.NAME from admin.SYS_ENTITIES E where E.K_ENTITY = V.K_DETAIL) as DETAIL_NAME, ";
    sql += "    (case V.K_DETAIL when -1 then 'Search' else 'Consult' end) as CONTEXT "; 
    sql += "from admin.QUERYVIEWS V ";
    sql += "where V.NAME = 'default' ";

    var ds = Database.ExecuteSystemSQLQuery(qh, tc, sql, "", true, false, 1);

    while (!ds.EoF){
            context = ds.FieldByName("CONTEXT").AsString,
            master = ds.FieldByName("MASTER_NAME").AsString,
            detail = ds.FieldByName("DETAIL_NAME").AsString,
            key = ds.FieldByName("K_QUERYVIEW").AsString;

        var section = context + master + "_";
        section += (context == "Consult")? detail + "_": "";
        section += "QueryView";

        Database.WriteString("Efficy", section, key);


The only thing you have to do after that is create a queryview where you want (it works for consult and search context, feel free to make it evolve if you need)

your query view has to be named : "Default" and be careful that your queryview is linked to everyone.

Best regards,

asked in Efficy/ Client side by (989 points)
You should not prefix the schema name "admin" in SQL queries. Use the tag <#TABLE NAME=SYS_ENTITIES> instead.

If you're default queryview does not apply additional filtering, consider changing the default query instead of working with a queryview
is the tagname working in the execSystemSQLQuery parameter?

plus my solution here is to give control over the default query to the customer. I don't want him to bother me every time he wants to change the default query...

ty for your answer.
Yes. This works

Please log in or register to answer this question.

1,248 questions
1,518 answers
328 users