How do i get the ci class for CI's listed in the change?

karanpreet
Tera Guru

Hello,

I have written a business rule to get a few details from a change like affected ci's ,start and end times.

But I want to make sure that I only make the rest call if it's a server CI. How can I get the details in the business rule?

The code is as follows:

try {

      var start_date = current.start_date.dateNumericValue()/1000;

      var end_date = current.end_date.dateNumericValue()/1000;

      var ps_dt = new GlideDateTime();

      var tz = Packages.java.util.TimeZone.getTimeZone("US/Central");

      ps_dt.setTZ(tz);

      var offset = ps_dt.getTZOffset()/1000;

      start_time = start_date + offset;

      end_time = end_date + offset;

      var target = new GlideRecord('task_ci');

      target.addQuery('task', current.sys_id);

      target.query();

      var r = new sn_ws.RESTMessageV2('Change_to_notes', 'post');      

      var request_body= '[';

      while(target.next()){

              gs.addInfoMessage(target.ci_item.name);

      }

      request_body = request_body.slice(0, -1);

      request_body = request_body + ']';

      r.setRequestBody(request_body);

      var response = r.execute();

}

catch(ex) {

      var message = ex.getMessage();

}

Thanks.

Regards,

Karan

1 ACCEPTED SOLUTION

Sanjeev Kumar1
Kilo Sage

Hi,



you can get class name using variable like.



var className = gr.ci_item.sys_class_name;



View solution in original post

2 REPLIES 2

Sanjeev Kumar1
Kilo Sage

Hi,



you can get class name using variable like.



var className = gr.ci_item.sys_class_name;



Thanks Sanjeev,



That worked perfectly.



Regards,


Karan