ServiceNow – Securing Fields – 3 UI Policies
foreign welcome to part three in this video series of securing fields in servicenow in this video we are going to discuss UI policies and I'm going to reiterate the point that I made with client Scripts like client scripts UI policies are no guarantee of data security use them for usability purposes sure Hyde Fields show Fields make them read only Etc but do not use them to enforce security okay let's take a look at some examples okay so we're going to use the same example that we did in the last video we are going to show and hide the pin field under certain conditions okay so let me go to servicenow studio and I have a simple UI policy here there are actually no conditions associated with this UI policy there are no UI policy actions actually everything I've got here is contained in a script it's a little bit nonsensical I wouldn't implement it like this in real life but just for demonstration purposes we have got a script here that basically evaluates whether the user has the car's admin role similar to our previous video with our client script and if they do have the card admin role we are going to show the pen field if not we are going to hide it so let me activate it and save it all right and let's go back to the record that we're using before so in this case we want to hide and show the pin field so for admins here if I just refresh this page it should actually be no change it's a cast admin I can see this just fine but if I come to a car's admin user and refresh this page suddenly that field is no longer there but just as we saw with client scripts I can come here in my browser and I can go to the source code for the page itself and we saw for a brief moment in time about half a second that that field did actually display before it was hidden by the script so it is actually there so if you come to the source code for the the page itself and go to well at the moment if we highlight that element there we're looking at the no pin field but if I come to the next form group div there and just drill down a little bit we can see here we've got the value for the pin right there 447 910 again no guarantee of data security it's not displayed on the form but just by looking at the source code for the page I can see the value easily enough okay so let's close that and let me come back to my admin and I'm just going to deactivate that UI policy right there and save it and let's look at another example all right so let's go to this one right here in this case if the no pin checkbox is set to true we are going to make the pin field read only okay let's see if that works it should this is a very basic configuration in the now platform so now if I come here to my form and again reload it okay if I select no pin to true that makes the pin field red only okay and I can save that just fine all right if I come over to my other user here you can see this value has been changed if I just refresh this here because that UI policy needs a chance to load in this page and now I can see that the pin field is shown if I deselect it here it's writable okay all right I could still go ahead and modify this value in the source code okay if I do that I'm just gonna maybe save this record again go back to servicenow Studio I'm going to make one to the UI policy action here so I will open it up now in addition to this field being read only I am going to hide it as well and I set visible to false and update that okay so let's check the result let's go to my peachy refresh the no pin flag has been set the true therefore that field is not there if I deselect it it's visible and I can change it okay that's fine all right let's go back to my car's user it should be the same behavior if I just refresh the page here just so that UI policy has a chance to load or the new version if I deselect no pin again visible I can change it select it it's gone okay now if I save it you may think that's the end of the story that can't see that field I can't change it well yeah I could just deselect that field but I could also do the following again we could go to the source code right click inspect okay initially the no P the no pen field is selected here but if I just scroll down a little bit further to the next form group here we can see the next field that's been hidden which is the PIN field itself and if I expand uh this branchy we can see the value 447-910 and guess what just like we could with our client script example before I can come in here and just change this to 999 999 enter okay now we don't see any change on the page itself here but we get an update button now so if I click that that record will be saved if I come back to my other session here you can see the value for pin has now been set to 999 999. so again the moral of this story once more is do not use UI policies just like client scripts for securing data in servicenow use them for usability purposes to ensure that you collect the data only when you need it show Fields when you need to show Fields make them read only when they need to be read only but do not rely on them for data security in the next video we are going to start now enforcing data security a little bit more using view rules so stay tuned for that one
https://www.youtube.com/watch?v=iiaCObelTZ0