- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2020 01:47 PM
I have a new table with two fields. Main field is a choice based on the Country field from the Location table. Client I'm working with isn't using default values, importing from external source, so need to get actual values from records and show those as choice options. On new table I'm using a UI Policy to make fields read only once both are selected, but conditions are false, use run script to populate list. Everything looks fine in Desktop UI, but Portal acts as if it's not processing UI Policy. Client is limiting Platform UI to admin and itil roles, so users updating/adding records should be using the Service Portal.
What's weird is that in my Orlando PDI, this works just fine, but in my New York one, it's acting the same as client's NY instance. When opening the table via the list portal page, everything works fine. However, when you open a record and it opens in the form portal page, Orlando processes the UI Policy correctly, but NY doesn't. The NY instance gives a Warning message when viewing the console log.
js_includes_sp.jsx?v=04-10-2020_1401&lp=Wed_Jun_03_08_06_06_PDT_2020&c=23_468:31531 UI Script does not return an object or function: ConditionalFocus
The UI Policy script is set to Run scripts in UI type = All. The script calls a GlideAjax and per HI KB, the additional function for the callback was placed in the getXML. Here's the UI Policy script for Execute if False.
function onCondition() {
//Type appropriate comment here, and begin script below
g_form.clearOptions('u_country');
//lookup existing values
var ga = new GlideAjax('SWUtils');
ga.addParam('sysparm_name', 'getCountries');
ga.getXML(function countryList(response) {
g_form.addOption('u_country', '', '--None--');
var answer = response.responseXML.documentElement.getAttribute("answer").split(',');
for (var i = 0; i < answer.length; i++) {
g_form.addOption('u_country', answer[i], answer[i]);
}
});
}
Again, not an Issue in an Orlando instance, but showing up in New York Patch 8. All g_form functions are Portal capable per docs.
Any thoughts or suggestions appreciated.
Adding script include being called.
var SWUtils = Class.create();
SWUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCountries: function() {
var cntry_array = [];
var cntry = new GlideRecord('cmn_location');
cntry.orderBy('country');
cntry.query();
while (cntry.next()) {
if (cntry.country != '') {
cntry_array.push(cntry.country + '');
}
}
var arrayUtil = new ArrayUtil();
cntry_array = arrayUtil.unique(cntry_array);
return cntry_array.toString();
},
type: 'SWUtils'
});
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 04:44 PM
Well, good news is that we're not crazy, this is an actual problem per ServiceNow found in New York and fixed in Orlando. They provided link to KB article on HI which says to "Wrap the script (the affected UI script) inside a self-invoking function...".
I didn't think it would work for either the Client Script or the UI Policy script as both have pre-defined function calls. I tried it anyways and got an error.
Here's the link to the article, but seems to be something that will need to be addressed with Orlando or above. https://hi.service-now.com/kb_view.do?sysparm_article=KB0748990
Thanks,
Dennis

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 07:41 AM
Hi,
Yea, I saw where you said that (twice or maybe three times now, lol). So I was proposing to try the client script I gave above.
Anyways, sorry I can't help further then.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2020 04:44 PM
Well, good news is that we're not crazy, this is an actual problem per ServiceNow found in New York and fixed in Orlando. They provided link to KB article on HI which says to "Wrap the script (the affected UI script) inside a self-invoking function...".
I didn't think it would work for either the Client Script or the UI Policy script as both have pre-defined function calls. I tried it anyways and got an error.
Here's the link to the article, but seems to be something that will need to be addressed with Orlando or above. https://hi.service-now.com/kb_view.do?sysparm_article=KB0748990
Thanks,
Dennis