Javascript in condition doesn't work

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

I'm trying to make a ui policy where some fields becomes read only if the user isnt a "manager" on the knowledge base that the article is connected to.

I'm doing like the picture below, but can't get it to work, no idea why.

ui policy 1.PNG

If I try this script in script-background it works as a charm.

var gr = new GlideRecord('kb_knowledge_base');

gr.addQuery('kb_managers','DOES NOT CONTAIN',gs.getUserID());

gr.query();

while(gr.next()){

gs.log("KB Base " + gr.title + " doesn't have your sys_id as manager");

}

Any clues?

1 ACCEPTED SOLUTION

Kalaiarasan Pus
Giga Sage

There was an problem long back when the conditions of UI policy with fields would not work, unless it was added on the form layout. Not sure if this is related to that problem.



But please modify the form layout, dot walk the knowledge base field and add the manager list field to the layout. That would make the UI policy work



4-11-2016 7-53-19 PM.png


View solution in original post

7 REPLIES 7

Kalaiarasan Pus
Giga Sage

There was an problem long back when the conditions of UI policy with fields would not work, unless it was added on the form layout. Not sure if this is related to that problem.



But please modify the form layout, dot walk the knowledge base field and add the manager list field to the layout. That would make the UI policy work



4-11-2016 7-53-19 PM.png


Thanks a lot! this was the problem. I added the field on the form and tada.. it started to work. So that pretty much mean that if you Dot-walk in a ui policy, you also must make sure that the field is on the form, otherwise the ui policy wont be able to access the values in that dot walked field... This is real good information!



Since this was a problem back then, should I report this as a bug? kalai ?



//Göran


Don't have a clue. Could be a known issue.



pradeepksharma Need your input!!!