- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:02 AM
Hi,
I am working on the Incident management where I have to capture the value of breach time(planned end date) field value,
I am trying with the below code with INC sys_id in background script it is giving the expected result but when using the same code in my Business Rule which is running on the Incident table where I have to capture the value of that field and have to hit other API for integration it is not giving the expected result...
var gr = GlideRecord('task_sla');
gr.addEncodedQuery('stage=in_progress^sla.target=resolution');
gr.addQuery('task','f2020ead1bd1f9101bc76280604bcb89');
gr.query();
if(gr.next()){
//obj_custom_field = gr.planned_end_time
gs.print(gr.planned_end_time);
}
Please help me with this...
Thanks in advance,
Atik
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:53 AM - edited 02-15-2024 02:56 AM
Hello @Atik ,
I have created a before insert and update business rule to retrieve the same and its returning the expected result, below is the screenshot.
(function executeRule(current, previous /*null when async*/) {
var grContract = new GlideRecord('contract_sla');
var gr = GlideRecord('task_sla');
gr.addQuery('task', current.sys_id);
gr.addEncodedQuery('stage=in_progress^sla.target=resolution');
//gr.addQuery('stage', 'in_progress');
gr.query();
if (gr.next()) {
//obj_custom_field = gr.planned_end_time
gs.log('BreachDateQuery ' + gr.planned_end_time.getDisplayValue());
}
})(current, previous);
Could you please let me know the exact scenario when you need this value, so that I can help you with the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:19 AM - edited 02-15-2024 02:21 AM
Hi @kps sumanth ,
below is the code which I had added in my business rule,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:33 AM
Hello @Atik ,
In line 3 the encoded query is having "grContract.target=resolution", I believe this is coming from sla definition and it should be sla.target=resolution.
Could you please let me know the use of this variable in your script "grContract".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 02:38 AM