Reference Qualifier not always working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 10:01 AM - edited 10-25-2024 10:03 AM
because of multiple domains, we need to track which domain request for firewall rule changes go to. This is defined in the Firewall Managers table, but not really. The device name relates to a Panorama device that was discovered in the Firewall Device table. In the Device table the dns domain is present but not in the Manager table.
When a request comes in for a change to a firewall rule the team needs to know which domain(s) this will be applied to. I am using the same reference qualifier for the Record Producer as I am on the table. My problem is that it does not always work for the Record Producer form. Here is the reference qualifier:
javascript: 'nameIN' + new CatalogClientUtils().GetFWManagerDevices();
Here is the scripts involved for this process in CatalogClientUtils():
GetRecord: function(myID, myTable){
//get a specific record from a specific table.
var outRecord = new GlideRecord(myTable);
if(outRecord.get(myID)){
return outRecord;
}
},
FWRulesFiltered: function(fManagers){
var ruleList = [];
var frGR = new GlideRecord('cmdb_ci_firewall_sec_policy_panorama');
frGR.addEncodedQuery('firewall_manager.nameIN' + fManagers);
frGR.query();
while (frGR.next()) {
//gs.info(frGR.name.toString() + ' : ' + frGR.firewall_manager.toString());
ruleList.push(frGR.getUniqueValue());
}
//return string for encoded query
return 'sys_idIN' + ruleList.join(',');
},
GetFWManagerDevices: function(){
var fmList = '';
var fmGR = new GlideRecord('cmdb_ci_firewall_manager_panorama');
fmGR.query();
while(fmGR.next()){
fmList += fmGR.getValue('name') + ',';
}
return fmList;
},
It was working fine for a while, now it is not, and is only returning 1 value (which is not one of the panoramas). In my test SN environment, this stopped working, and today it does work... I must be doing something very poorly...
On the table (in the record form) this always works as expected. It has not failed. So something to do with when in the portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 12:02 PM
I've always returned a list of sys_ids to a reference qualifier. It must be possible with other fields, like name, but probably not the best choice as others fields are not necessarily unique. Try this:
javascript: 'sys_+idIN' + new CatalogClientUtils().GetFWManagerDevices();
And here's a better approach to building the list:
GetFWManagerDevices: function(){
var fmArr = [];
var fmGR = new GlideRecord('cmdb_ci_firewall_manager_panorama');
fmGR.query();
while (fmGR.next()) {
fmArr.push(fmGR.getValue('sys_id'));
}
return fmArr.join(',');
},
If this doesn't clear up the erratic behavior, ensure that you do not have any other Script Includes with the same name. Is everything in the Global scope, or is the Record Producer or Script Include in an Application?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 08:28 AM
The reason I need to get the name is that I need to reference the name found in the Firewall Manager table to the device on the Firewall Device table. The DNS information is only on the latter table, and the only connection is the name of the device. Your above script will return something I cannot look up for in the Device table.
This process works 100% of the time from the record view, but fails very often in the Catalog Item (portal view).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 09:45 AM
It is technically possible to duplicate Script Include names, so make sure you only have one named CatalogClientUtils. Is your Script Include in the same scope as the Record Producer, and are you testing with a user that has the role listed in the Access Controls related list on the Script Include, if there are any?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2024 10:22 AM
Well, turns out that the issue was more of a redirect problem. In our lower environments the link to our Portal was set to our PROD instance, which does not yet have all the data. Which is why it was failing. In my first tests, I must have typed in the URL for the Portal (or went off the Catalog Item Try it link) when it was working... Thanks though for your input. When I can, I will try to use the sys_id over all other values.
Using the proper links has the function working. Now to move up to PROD after the other discovery data is set.