- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2024 02:20 AM
I have two reference fields on a form. one is platform and second one is CMDB. CMDB is on task table. platform field is getting data from data management table and CMDB is getting data from cmdb_ci table. data management table having a list field which is reference to CMDB. when CMDB field is filled i need the reference qualifier to show only records related to that CMDB field.
script include:
var app = current.cmdb_ci;
var gr = new GlideRecord(‘table name);
gr.addQuery(‘u_applications’, app);
gr.query();
var result = [];
while(gr.next()){
result.push(gr.sys_id);
return result;
}
advanced ref qualifier : javascript: new script include name().function();
please help in this.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-28-2024 05:45 AM - edited ‎10-28-2024 05:54 AM
Hi @Kumar147 ,
You have not followed my instruction.
Not sure why you are writing script include.
Just add below code in your reference qualifier of plateform filed. nothing else is required.
javascript:'u_cmdb_listLIKE'+current.cmdb_ci
replace "u_cmdb_list" with your field name which present on your data management table.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2024 02:45 AM
Hi @Kumar147 ,
Can you add a log message after var app = current.cmdb_ci, like
gs.log('App value: ' + app);
I believe you cannot access current object in script include like you use current in business rule.
Possibly, you can pass the parameter current from the reference qualifier and return the results; like below
Qualifier: javascript: new script_include_name().function(current);
Script Include:
var MyScriptInclude = Class.create();
MyScriptInclude.prototype = {
initialize: function() {},
getRecords: function(current) {
var app = current.cmdb_ci;
var gr = new GlideRecord('table_name'); // Replace 'table_name' with the actual table name
gr.addQuery('u_applications', app);
gr.query();
var result = [];
while (gr.next()) {
result.push(gr.sys_id.toString());
}
return result;
},
type: 'MyScriptInclude'
};
If the above information helps you, Kindly mark it as Helpful and Accept the solution.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2024 02:50 AM
Hello @Najmuddin Mohd
I have already tried removing current and passed the parameter in reference qualifier like javascript: new script include().function(current.cmdb);
but noluck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2024 04:06 AM
Hi @Kumar147 ,
Simply put the reference qualifier like below
javascript:'u_cmdb_listLIKE'+current.cmdb_ci
replace "u_cmdb_list" with your field name which present on your data management table.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
LinkedIn: https://www.linkedin.com/in/runjay
YouTube: https://www.youtube.com/@RunjayP
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2024 04:08 AM
Hello @Runjay Patel,
I have tried this javascript: ‘u_app_platform=‘+current.cmdb_ci;
but not worked.