- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 05:24 AM
Hi All,
I have a record producer that will be used on our Service Portal.
This has the variable u_brands (Are any of your brands affected?). I need the answer from this to filter the choices available in the u_envi variable (Which environment is affected, if known?).
u_brands is a reference of the core_company table and u_envi is a lookup select box of the cmdb_ci_environment table.
I've tried to create a script includes to use in the reference qualifier of the u_envi variable, however it is just showing every environment rather than filtering on the answer from u_brands.
As can see from the screenshots I am only expecting to see the 1Answer Network Live (Classic) environment with the brand boxeo selected.
Any help is greatly appreciated.
Reference qual:
javascript: new company_user().getEnv(current.variables.u_brands);
Script includes:
getEnv : function(u_brands){
var brand = u_brands;
var env = newGlideRecord('cmdb_ci_environment');
env.addQuery('company', brand);
env.query();
while(env.next()){
sysid.push(env.name.toString());
}
return 'sys_idIN'+sysid.join(',');
},
type: 'company_user'
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 07:36 AM
So you have only 2 records, You need to check the System Logs -> All module to view the log. Please try this out once
getEnv : function(u_brands){
var sysid = '';
var brand = u_brands;
if(brand == ''){
return 'sys_idIN';
}else{
var env = new GlideRecord('cmdb_ci_environment');
env.addQuery('company', brand);
env.query();
while(env.next()){
sysid += "," + env.sys_id;
}
return 'sys_idIN'+sysid.substring(1);
}
},
type: 'company_user'
});
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 07:10 AM
Try this one for empty brands
getEnv : function(u_brands){
var sysid = [];
var brand = u_brands;
if(brand == ''){
return 'sys_idIN';
}else{
var env = new GlideRecord('cmdb_ci_environment');
env.addQuery('company', brand);
env.query();
while(env.next()){
sysid.push(env.sys_id);
}
return 'sys_idIN'+sysid.join(',');
}
},
type: 'company_user'
});
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 07:17 AM
Hi Alikutty,
That's great for the empty brands,
Just need it to return all the environments for the company if the company has more that 1?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 07:26 AM
It should have returned all of the brands, Can you please apply the company filter on the cmdb_ci_environment table and see if it returns all data? Also please log the sys_id and paste the value here
getEnv : function(u_brands){
var sysid = [];
var brand = u_brands;
if(brand == ''){
return 'sys_idIN';
}else{
var env = new GlideRecord('cmdb_ci_environment');
env.addQuery('company', brand);
env.query();
while(env.next()){
sysid.push(env.sys_id);
}
gs.log(sysid.join(','));
return 'sys_idIN'+sysid.join(',');
}
},
type: 'company_user'
});
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 07:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2017 07:36 AM
So you have only 2 records, You need to check the System Logs -> All module to view the log. Please try this out once
getEnv : function(u_brands){
var sysid = '';
var brand = u_brands;
if(brand == ''){
return 'sys_idIN';
}else{
var env = new GlideRecord('cmdb_ci_environment');
env.addQuery('company', brand);
env.query();
while(env.next()){
sysid += "," + env.sys_id;
}
return 'sys_idIN'+sysid.substring(1);
}
},
type: 'company_user'
});
Thank You
Please Hit Like, Helpful or Correct depending on the impact of response