- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2023 11:57 PM
I don't know why it doesn't want to be done
var database = new GlideRecord('cmdb_ci_database');
database.query();
// I go through the database and get the application name
// if the application field is not empty, it will execute the contents of if
// I get the value from cmdb_ci_service by what the function returns, if it is not empty, I enter it into the DATABASE)
while (database.next()){
var applicationName = database.u_application;
if(applicationName !== null)
{
var adminGroup = getAdminGroup(applicationName);
if(adminGroup !== null)
{
database.support_group=adminGroup;
database.update();
}
}
}
function getAdminGroup(applicationName)
{
var service = new GlideRecord('cmdb_ci_service');
service.addQuery('name',applicationName);
service.query();
if (service.next()){
return service.u_grupa_administracyjna;
}
return null;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 12:19 AM
Hi @Pawel Barcik ,
Can u try the below code please:
var database = new GlideRecord('cmdb_ci_database');
database.query();
// I go through the database and get the application name
// if the application field is not empty, it will execute the contents of if
// I get the value from cmdb_ci_service by what the function returns, if it is not empty, I enter it into the DATABASE)
while (database.next()){
var applicationName = database.u_application;
if(applicationName !== null)
{
var adminGroup = getAdminGroup(applicationName);
if(adminGroup !== null)
{
database.support_group=adminGroup;
database.update();
}
}
}
function getAdminGroup(applicationName)
{
var service = new GlideRecord('cmdb_ci_service');
service.addQuery('sys_id',applicationName);
service.query();
if (service.next()){
return service.u_grupa_administracyjna.toString();
}
return null;
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 12:02 AM
Hi,
What is field type for u_application & u_grupa_administracyjna? Reference or free text field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 12:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 12:13 AM - edited 11-06-2023 12:15 AM
Hi @Pawel Barcik ,
What about u_application name field wht is the type of that?
For the other field can u try replacing the line
return service.u_grupa_administracyjna;
//with
return service.u_grupa_administracyjna.toString();
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 12:17 AM
