- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2016 04:22 AM
I have a requirement where I have three variables in service catalog
1. CI Type(select box) -> VM , Linux , ESX, JBOSS
2. CI Name (reference field)
3. Sys ID (single line text)
Now I want that whenever the CI type is changing the referenced table in CI Name should change accordingly with their respective tables.
like for vm ->cmdb_ci_vm similarly for others as well.
My end result is to fetch selected ci name's sys id .
For changing reference field script include and onchange client script will be required .
for sysid fetch also onchange or onsubmit script will be required . Not sure about this
Please help me with the correct code for my requirement .
Let me know if you need any further information.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2016 02:13 AM
Please replace-
var type=current.u_type;
with
var type=current.variables.u_type;
It should work now. Best of luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2016 06:45 PM
Sorry Aastha it was my mistake....
We are setting the query in the variable qualifier and returning grpID
please replace return grpID;
with return qualifier;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2016 01:05 AM
I can still see configuration item table and its not changing when I am selecting linux or esx.
Am I doing correctly where is the issue I am not able to understand.
Script Include:
var TestScript = Class.create();
TestScript.prototype = {
initialize: function() {
},
getCIbasedonClass : function()
{
var type=current.vm_type;// select box fields(Please replace ci_type with the name of selectbox
var qualifier='';
if(type=='esx')//value of the choice field eg.ESX
{
qualifier="sys_class_name=cmdb_ci_esx_server";//Query which we copied
return qualifier;
}
else if(type=='linux')
{
qualifier="sys_class_name=cmdb_ci_linux_server"; // Put the query for linux server
return qualifier;
}
},
type: 'TestScript'
};
Javascript code :
javascript:new TestScript().getCIbasedonClass()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2016 06:58 PM
Hi,
Look following it will help you
Reference Qualifiers - ServiceNow Wiki
Advanced reference qualifier example
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2016 01:18 AM
You can put log statement in in script include and check the logs whether type is coming as you are changing the value.
insert-
gs.log('type is : '+type);
after you declared the qualifier variable. check the logs and confirm. what is the name of the script include which you wrote please confirm. Also confirm the field name of the dropdown and the choice values.
Check the logs after changing the values of the dropdown field in the form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2016 01:28 AM