Make location inactive?

Heather White
Mega Guru

Good morning,

      Is there a way to make locations inactive in ServiceNow?   We imported current(updated) locations from AD and users now have the correct locations within their company.   However, the "old" locatoins are still available in the drop down menu.   We do not want users to see these depricated locations.

Thank you!

Heather

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Heather,



Here's how I would handle this - without deleting any of the previous records, because deleting can cause issues with broken references.


  1. Create a new field on the location (cmn_location) called Active (u_active) and make it a true/false field.
  2. Make the locations you want to appear active (true) and those that you don't, leave unchecked.
  3. Create a before/query business rule that automatically filters for the active records only. Use the "user query" business rule as an example (substitute YOURINSTANCE for your instance name in the following URL
    1. https://YOURINSTANCE.service-now.com/nav_to.do?uri=sys_script.do?sys_id=62a7bfaf0a0a0a6500c49682bd82...

View solution in original post

21 REPLIES 21

Thank you Chuck!   I will take a look at this episode-I just learned about reference qualifiers as well(when I found one in an unexpected place!)   I will try your first solution, as I have a few locations to handle.


Regards,


Heather


You are welcome Heather. If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.



If you are viewing this from the community inbox you will not see the correct answer button.   If so, please review How to Mark Answers Correct From Inbox View.



Thank you


Chuck,



      I am having a bit of trouble with the business rule-I have used the user query as an example, but I believe my condition is incorrect for location, and my script is possibly incorrect(I am new to scripting).


The condition I am using is:


gs.getSession().isInteractive() && !gs.hasRole("admin") && !gs.hasRole("user_create")



My script is this:


current.addActiveQuery();



Can you advise on how I would change this script?  


Thanks!



Heather


Hi Heather,



the addActiveQuery() method only works if there is a field called 'active'. Since you added it, the field is called u_active. Instead, use this query



current.addQuery('u_active', true);



(FWIW, I do this kind of thing all the time.)


Thank you Cheyenne, this would work well for some of my smaller companies!