Make a system property where the choices should be like a "reference field"

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Im wondering if it is possible to have a system property that has a choice list that is populated with data from another table.

My scenario is like this:

I want to make a system property that when we go to the property page will be like a reference field to our knowledge articles. Is it possible to somehow write javascript in the "choice" field in the property to fetch the articles I want to show? like a specific category or name starts with something etc...

Hope my question is clear enough.

//göran

5 REPLIES 5

Brian Dailey1
Kilo Sage

Hi Goran,



If you wanted a drop-down choice list of items populated from another table, you could try including your choice property on a UI Page and then using the g_form method "addOption()" to loop through the records you want and insert your choice list. (GlideForm (g form) - ServiceNow Wiki )



For an example within an existing UI Page, look at the Client Script for the page "approval_engines" used for System Properties.   It uses addOption in this way.   Or for more examples, just filter your list of UI Pages where Client Script contains "addOption".   You could call a client-side GlideRecord (or write something using AJAX) to pull your list of records from whatever table, and then loop through the records to build your choices.



If you're talking about a large table though, this wouldn't be too practical.   This is more for something like a list of category values, etc.



It would be nice if they allowed use of javascript in the Choices field for a system property definition, but that didn't appear to work when I tested it.




Thanks,


-Brian


Hi Brian,



Yea, throwing up an UI page is my second option. I just wanted to use the OOB functions with system properties and categories to simply thrown them together with a module like: system_properties_ui.do?sysparm_title=New features properties&sysparm_category=New feature popup windows.



Then I didn't need to scrap together a ui page. But perhaps that's the only option.


Hi Goran,



If it's a known (and fairly static) list of categories, you can enter then as a comma-separated list in the Choices field on the dictionary record of the reference field.   This is where it would be nice of them to allow for using "javascript:..." to populate the list dynamically.



But also, without a UI page to wrap it, I don't see Choice-type system properties being presented with a drop-down of choices... they seem to be treated simply as a text entry both on form an list-edit views.   Not sure why this is if you are specifying that it should be a choice in the property's definition.




-Brian


Hmm.. You can have it as a dropdown. Look for example on the "standard change properties" module. But then again.. I need to manually fill the choices which I dont and sadly my list won't be static enough to have it manually.