Catalog Client Script not setting the reference variable using URL parameter (value keeps reverting)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi team,
I’m working on a Catalog Client Script (onLoad) where I need to populate a reference variable (configuration_item) based on a URL parameter ci=1.
OnLoad script:
function onLoad() {
var ci = g_form.getParameter('ci');
g_form.clearValue('configuration_item');
if (ci === '1') {
g_form.setValue('configuration_item', 'sys_id');
}
}
The variable still loads the previously used value, even after
clearValue().
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @SwethanaB ,
try this script :
function onLoad() {
var ci= getParameterValue('ci');
if(ci == '1'){
g_form.clearValue('configuration_item');
g_form.setValue('configuration_item','sys_id');
}
}
function getParameterValue(name) {
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
}
If my response helped mark as helpful and accept the solution.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Also ensure catalog client script > ui type is set to -> ALL
