How to get a field from a related list

d-aizawa
Kilo Sage

I created a Factor Type field in the Problem table.

Factor Type
Table : problem
Type : String
Column name : u_factor_type
Choice value

  • internal_factor
  • external_factor
  • other

I want to see the fields below to auto-set the Factor Type field choices

Damage
Table : cmdb_ci_outage
Type : String
Column name : u_damage
Choice value

  • having
  • nothing
  • other

Is there a way to get the information of the Incident record
from the related list of the Problem record and then the fields of the Outage record?

Thank you

find_real_file.png

find_real_file.png

find_real_file.png

 

1 ACCEPTED SOLUTION

Hi,

This is how you can get the outage related with problem.

var incGr = new GlideRecord('incident');
incGr.addQuery('problem_id',current.getUniqueValue());
incGr.query();
while(incGr.next()){
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('task_number',incGr.getUniqueValue());
outageGr.query();
while(outageGr.next()){
gs.info('Damange :'+outageGr.u_damage);
}
}

 

Here current refers to the problem record.

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

8 REPLIES 8

Thank you for your reply.

One thing to check, is that script a Business Rule?

Thank you!

You can use it in business rule running on problem table.

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

If you want to run it in background script:

var incGr = new GlideRecord('incident');
incGr.addQuery('problem_id','sys_id of problem here'); // replace problem sys_id 
incGr.query();
while(incGr.next()){
var outageGr = new GlideRecord('cmdb_ci_outage');
outageGr.addQuery('task_number',incGr.getUniqueValue());
outageGr.query();
while(outageGr.next()){
gs.info('Damange :'+outageGr.u_damage);
}
}

 

 

Thanks,

Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Thank you for your reply.

I want to use client script.

But, I know that Using Glide Record in client scripts is deprecated as it degrades performance.

I think I'll be using Glide ajax and Script Include, but what about?

Thank you!