when i edit the change planned start and end date in change record new change task is created
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 09:29 AM
Hi,
Could any one help me on this!!
When i try to edit the start and end date of the existing change request, corresponding dates are not updated in the change task. Instead it is creating the change task newly.
Below is the code i am using :
BR( after, Update) ;
Filter condition: When Planned start and end date changes
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('change_task');
gr.addQuery('change_request',current.sys_id);
gr.query();
if(gr.next())
{
gr.planned_start_date = current.start_date;
gr.planned_end_date = current.end_date;
gr.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 03:49 AM
Yes sure Sandeep i am pasting the code of BR(after,update) on the change_request table.
Below is the code i am using :
BR( after, Update) ;
Filter condition: When Planned start and end date changes
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('change_task');
gr.addQuery('change_request',current.sys_id);
gr.query();
if(gr.next())
{
gr.planned_start_date = current.start_date;
gr.planned_end_date = current.end_date;
gr.update();
}
})(current, previous);
Also i did some of the minor changes in the code as suggested by Johns but no luck with that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 04:23 AM
Script looks fine to me, chances of insertion of a new change task is bleak here as you already have an if check placed if(gr.next()) which will make sure that an existing record is updated and not a new record is inserted. Can you put a gs.info ('Change task sys_id'+gr.getValue('sys_id')); inside the if statement and check if the update is made to the correct change task or not.