Not working as expected

Sathwik1
Tera Expert

In portal, for a page under the "Can View" section, I mapped a user criteria for it.. and I used advance scripting over there.. and while testing I don't see logs are getting generated.. can anyone please help me to understand on why LOGS are not getting Generated? It makes me feel like user criteria it's self is not working..

answer = AccessValidation();

function AccessValidation() {
    var UserID = gs.getUserName();
    gs.info("Sathwik Entered");
    var gr = new GlideRecord('sys_user');
    gr.addEncodedQuery('user_name=' + UserID');
    gr.query();
    if (gr.next()) {
        gs.info("Sathwik found");
        return true;
    } else {
        gs.info("Sathwik not found");
        return false;
    }
}

@Ankur Bawiskar 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Sathwik1 

where did you add that? share screenshot

try this script

answer = AccessValidation();

function AccessValidation() {
    var gr = new GlideRecord('sys_user');
    gr.addEncodedQuery('sys_id=' + user_id);
    gr.query();
    if (gr.next()) {
        gs.info("Sathwik found");
        return true;
    } else {
        gs.info("Sathwik not found");
        return false;
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

17 REPLIES 17

Ankur Bawiskar
Tera Patron
Tera Patron

@Sathwik1 

where did you add that? share screenshot

try this script

answer = AccessValidation();

function AccessValidation() {
    var gr = new GlideRecord('sys_user');
    gr.addEncodedQuery('sys_id=' + user_id);
    gr.query();
    if (gr.next()) {
        gs.info("Sathwik found");
        return true;
    } else {
        gs.info("Sathwik not found");
        return false;
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Portal -> HomePage -> In homepage related list we had an option as "Can View" -> In "Can View", I linked with an user criteria, in that user critieria, I had added the above code. @Ankur Bawiskar 

Not working

@Sathwik1 

any docs which says it gets evaluated?

share screenshot, I couldn't find this

Portal -> HomePage -> In homepage related list we had an option as "Can View" -> In "Can View", I linked with an user criteria, in that user critieria

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader