how to glide two tables in a function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2022 06:48 PM
Hello all,
I am working on a requirement wherein I am gliding two tables in a function, wanted to know how to go about it.
This is the code I have written for a script include :
copyServiceMappingEntries: function() {
// Get existing associations
var grServices = this._getAllAssociations();
},
_getAllAssociations: function() {
var gr = new GlideRecord("svc_ci_assoc");
gr.query();
return gr;
if(gr.next())
{
return gr;
}
else
{
var grRel = new GlideRecord('cmdb_rel_ci');
grRel.addEncodedQuery('type=1a9cb166f1571100a92eb60da2bce5c5^parent.sys_class_name=cmdb_ci_service');
grRel.query();
return grRel;
}
},
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 07:02 AM
hi,
can you be a little more specific .
The requirement it that it glides the assoc table and see if there is a CI in it if the CI is not there then use the cmdb rel ci table .
how can I go about this code for this requirement ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2022 07:45 AM
this is what i updated :
_getAllAssociations: function() {
var gr = new GlideRecord("svc_ci_assoc");
gr.addEncodedQuery('service_id.service_classificationINBusiness Service,Application Service,Technical Service')
gr.query();
if(gr.next())
{
return gr;
}
else
{
var grRel = new GlideRecord('cmdb_rel_ci');
grRel.addEncodedQuery('type=1a9cb166f1571100a92eb60da2bce5c5^parent.sys_class_name=cmdb_ci_service');
grRel.query();
return grRel;
}