- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 12:31 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 12:42 AM
Hi,
you can get class name using variable like.
var className = gr.ci_item.sys_class_name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 12:42 AM
Hi,
you can get class name using variable like.
var className = gr.ci_item.sys_class_name;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2017 02:38 AM
Thanks Sanjeev,
That worked perfectly.
Regards,
Karan