want to populate description field only when selected CI's class is Application service

Avee90
Tera Contributor

Hello All,

   I want to populate description field only when the selected configuration item's class is 'Application service' in configuration item field using script include and client script. I tried but no luck because of every class in configuration item is referring to a table. I glided the cmdb_ci as grCI table and used if(grCI.sys_class_name== cmdb_ci_service_auto) but it is not fetching the the CI's which are under Application Service class.
I copied the query from cmdb_ci table as class is Application service and got this query as sys_class_name=cmdb_ci_service_auto and I used this in script but not working. Can anyone help me on the script include

Script inlude:

 

               configurationItem: function(){

                              var applicationService= this.getParameter('sysparm_ci');

                              var grCI= new GlideRecord('cmdb_ci');
                              grCI.query();

                              while(grCI.next()){

                              if(grCI.sys_class_name== cmdb_ci_service_auto'){

                                             return true;

                              }  else {

                        return false;

                       }                          

               },

   

Even the selected CI's class is 'Application Service' then also not working not going into if loop.
Client script is working fine
Thanks in advance

4 REPLIES 4

Mark Manders
Mega Patron

Please provide your client script and script include so we can see where it's going wrong. 

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Yes, Adding the script in my post

 

Pratiksha
Mega Sage
Mega Sage

Are you trying to do this on incident form? Use case : when you populate ci which is application service then you want to auto populate description. 

 

Question : Is it any fix value you want to populate or something from the application service? 

I want to populate description field on Change form when the selected CI's class only Application Service. I'm adding the script in my post.